home *** CD-ROM | disk | FTP | other *** search
/ Chip 1996 September / CHIP Eylül 1996.iso / utils / povray / povsrc.sea / POVSRC / SOURCE / GIFDECOD.C < prev    next >
MacBinary  |  1993-08-06  |  15.5 KB  |  [TEXT/MPS ]

open in: MacOS 8.1     |     Win98     |     DOS

browse contents    |     view JSON data     |     view as text


This file was processed as: MacBinary (archive/macBinary).

ConfidenceProgramDetectionMatch TypeSupport
66% dexvert Compact Compressed (Unix) (archive/compact) ext Supported
10% dexvert MacBinary (archive/macBinary) fallback Supported
1% dexvert Text File (text/txt) fallback Supported
100% file MacBinary II, inited, Fri Aug 6 14:58:04 1993, modified Fri Aug 6 14:58:04 1993, creator 'MPS ', type ASCII, 15210 bytes "GIFDECOD.C" , at 0x3bea 428 bytes resource default (weak)
99% file data default
74% TrID Macintosh plain text (MacBinary) default
25% TrID MacBinary 2 default (weak)
100% lsar MacBinary default


id metadata
keyvalue
macFileType[TEXT]
macFileCreator[MPS ]



hex view
+--------+-------------------------+-------------------------+--------+--------+
|00000000| 00 0a 47 49 46 44 45 43 | 4f 44 2e 43 00 00 00 00 |..GIFDEC|OD.C....|
|00000010| 00 00 00 00 00 00 00 00 | 00 00 00 00 00 00 00 00 |........|........|
|00000020| 00 00 00 00 00 00 00 00 | 00 00 00 00 00 00 00 00 |........|........|
|00000030| 00 00 00 00 00 00 00 00 | 00 00 00 00 00 00 00 00 |........|........|
|00000040| 00 54 45 58 54 4d 50 53 | 20 01 00 00 00 00 00 00 |.TEXTMPS| .......|
|00000050| 00 00 00 00 00 3b 6a 00 | 00 01 ac a8 88 5a 3c a8 |.....;j.|.....Z<.|
|00000060| 88 5a 3c 00 00 08 00 00 | 00 00 00 00 00 00 00 00 |.Z<.....|........|
|00000070| 00 00 00 00 00 00 00 00 | 00 00 81 81 e7 04 00 00 |........|........|
|00000080| 2f 2a 2a 2a 2a 2a 2a 2a | 2a 2a 2a 2a 2a 2a 2a 2a |/*******|********|
|00000090| 2a 2a 2a 2a 2a 2a 2a 2a | 2a 2a 2a 2a 2a 2a 2a 2a |********|********|
|000000a0| 2a 2a 2a 2a 2a 2a 2a 2a | 2a 2a 2a 2a 2a 2a 2a 2a |********|********|
|000000b0| 2a 2a 2a 2a 2a 2a 2a 2a | 2a 2a 2a 2a 2a 2a 2a 2a |********|********|
|000000c0| 2a 2a 2a 2a 2a 2a 2a 2a | 2a 2a 2a 2a 2a 0d 2a 20 |********|*****.* |
|000000d0| 20 20 20 20 20 20 20 20 | 20 20 20 20 20 20 20 20 | | |
|000000e0| 20 20 67 69 66 64 65 63 | 6f 64 2e 63 0d 2a 0d 2a | gifdec|od.c.*.*|
|000000f0| 20 20 47 49 46 2d 73 74 | 79 6c 65 20 4c 5a 57 20 | GIF-st|yle LZW |
|00000100| 64 65 63 6f 64 65 72 2e | 0d 2a 0d 2a 20 20 4e 4f |decoder.|.*.* NO|
|00000110| 54 45 3a 20 20 50 6f 72 | 74 69 6f 6e 73 20 6f 66 |TE: Por|tions of|
|00000120| 20 74 68 69 73 20 6d 6f | 64 75 6c 65 20 77 65 72 | this mo|dule wer|
|00000130| 65 20 77 72 69 74 74 65 | 6e 20 62 79 20 53 74 65 |e writte|n by Ste|
|00000140| 76 65 20 42 65 6e 6e 65 | 74 74 20 61 6e 64 20 61 |ve Benne|tt and a|
|00000150| 72 65 20 75 73 65 64 0d | 2a 20 20 20 20 20 20 20 |re used.|* |
|00000160| 20 20 68 65 72 65 20 77 | 69 74 68 20 68 69 73 20 | here w|ith his |
|00000170| 70 65 72 6d 69 73 73 69 | 6f 6e 2e 0d 2a 0d 2a 20 |permissi|on..*.* |
|00000180| 20 66 72 6f 6d 20 50 65 | 72 73 69 73 74 65 6e 63 | from Pe|rsistenc|
|00000190| 65 20 6f 66 20 56 69 73 | 69 6f 6e 20 52 61 79 74 |e of Vis|ion Rayt|
|000001a0| 72 61 63 65 72 0d 2a 20 | 20 43 6f 70 79 72 69 67 |racer.* | Copyrig|
|000001b0| 68 74 20 31 39 39 33 20 | 50 65 72 73 69 73 74 65 |ht 1993 |Persiste|
|000001c0| 6e 63 65 20 6f 66 20 56 | 69 73 69 6f 6e 20 54 65 |nce of V|ision Te|
|000001d0| 61 6d 0d 2a 2d 2d 2d 2d | 2d 2d 2d 2d 2d 2d 2d 2d |am.*----|--------|
|000001e0| 2d 2d 2d 2d 2d 2d 2d 2d | 2d 2d 2d 2d 2d 2d 2d 2d |--------|--------|
|000001f0| 2d 2d 2d 2d 2d 2d 2d 2d | 2d 2d 2d 2d 2d 2d 2d 2d |--------|--------|
|00000200| 2d 2d 2d 2d 2d 2d 2d 2d | 2d 2d 2d 2d 2d 2d 2d 2d |--------|--------|
|00000210| 2d 2d 2d 2d 2d 2d 2d 2d | 2d 2d 2d 2d 2d 2d 2d 0d |--------|-------.|
|00000220| 2a 20 20 4e 4f 54 49 43 | 45 3a 20 54 68 69 73 20 |* NOTIC|E: This |
|00000230| 73 6f 75 72 63 65 20 63 | 6f 64 65 20 66 69 6c 65 |source c|ode file|
|00000240| 20 69 73 20 70 72 6f 76 | 69 64 65 64 20 73 6f 20 | is prov|ided so |
|00000250| 74 68 61 74 20 75 73 65 | 72 73 20 6d 61 79 20 65 |that use|rs may e|
|00000260| 78 70 65 72 69 6d 65 6e | 74 0d 2a 20 20 77 69 74 |xperimen|t.* wit|
|00000270| 68 20 65 6e 68 61 6e 63 | 65 6d 65 6e 74 73 20 74 |h enhanc|ements t|
|00000280| 6f 20 50 4f 56 2d 52 61 | 79 20 61 6e 64 20 74 6f |o POV-Ra|y and to|
|00000290| 20 70 6f 72 74 20 74 68 | 65 20 73 6f 66 74 77 61 | port th|e softwa|
|000002a0| 72 65 20 74 6f 20 70 6c | 61 74 66 6f 72 6d 73 20 |re to pl|atforms |
|000002b0| 6f 74 68 65 72 20 0d 2a | 20 20 74 68 61 6e 20 74 |other .*| than t|
|000002c0| 68 6f 73 65 20 73 75 70 | 70 6f 72 74 65 64 20 62 |hose sup|ported b|
|000002d0| 79 20 74 68 65 20 50 4f | 56 2d 52 61 79 20 54 65 |y the PO|V-Ray Te|
|000002e0| 61 6d 2e 20 20 54 68 65 | 72 65 20 61 72 65 20 73 |am. The|re are s|
|000002f0| 74 72 69 63 74 20 72 75 | 6c 65 73 20 75 6e 64 65 |trict ru|les unde|
|00000300| 72 0d 2a 20 20 77 68 69 | 63 68 20 79 6f 75 20 61 |r.* whi|ch you a|
|00000310| 72 65 20 70 65 72 6d 69 | 74 74 65 64 20 74 6f 20 |re permi|tted to |
|00000320| 75 73 65 20 74 68 69 73 | 20 66 69 6c 65 2e 20 20 |use this| file. |
|00000330| 54 68 65 20 72 75 6c 65 | 73 20 61 72 65 20 69 6e |The rule|s are in|
|00000340| 20 74 68 65 20 66 69 6c | 65 0d 2a 20 20 6e 61 6d | the fil|e.* nam|
|00000350| 65 64 20 50 4f 56 4c 45 | 47 41 4c 2e 44 4f 43 20 |ed POVLE|GAL.DOC |
|00000360| 77 68 69 63 68 20 73 68 | 6f 75 6c 64 20 62 65 20 |which sh|ould be |
|00000370| 64 69 73 74 72 69 62 75 | 74 65 64 20 77 69 74 68 |distribu|ted with|
|00000380| 20 74 68 69 73 20 66 69 | 6c 65 2e 20 49 66 20 0d | this fi|le. If .|
|00000390| 2a 20 20 50 4f 56 4c 45 | 47 41 4c 2e 44 4f 43 20 |* POVLE|GAL.DOC |
|000003a0| 69 73 20 6e 6f 74 20 61 | 76 61 69 6c 61 62 6c 65 |is not a|vailable|
|000003b0| 20 6f 72 20 66 6f 72 20 | 6d 6f 72 65 20 69 6e 66 | or for |more inf|
|000003c0| 6f 20 70 6c 65 61 73 65 | 20 63 6f 6e 74 61 63 74 |o please| contact|
|000003d0| 20 74 68 65 20 50 4f 56 | 2d 52 61 79 0d 2a 20 20 | the POV|-Ray.* |
|000003e0| 54 65 61 6d 20 43 6f 6f | 72 64 69 6e 61 74 6f 72 |Team Coo|rdinator|
|000003f0| 20 62 79 20 6c 65 61 76 | 69 6e 67 20 61 20 6d 65 | by leav|ing a me|
|00000400| 73 73 61 67 65 20 69 6e | 20 43 6f 6d 70 75 53 65 |ssage in| CompuSe|
|00000410| 72 76 65 27 73 20 47 72 | 61 70 68 69 63 73 20 44 |rve's Gr|aphics D|
|00000420| 65 76 65 6c 6f 70 65 72 | 27 73 0d 2a 20 20 46 6f |eveloper|'s.* Fo|
|00000430| 72 75 6d 2e 20 20 54 68 | 65 20 6c 61 74 65 73 74 |rum. Th|e latest|
|00000440| 20 76 65 72 73 69 6f 6e | 20 6f 66 20 50 4f 56 2d | version| of POV-|
|00000450| 52 61 79 20 6d 61 79 20 | 62 65 20 66 6f 75 6e 64 |Ray may |be found|
|00000460| 20 74 68 65 72 65 20 61 | 73 20 77 65 6c 6c 2e 0d | there a|s well..|
|00000470| 2a 0d 2a 20 54 68 69 73 | 20 70 72 6f 67 72 61 6d |*.* This| program|
|00000480| 20 69 73 20 62 61 73 65 | 64 20 6f 6e 20 74 68 65 | is base|d on the|
|00000490| 20 70 6f 70 75 6c 61 72 | 20 44 4b 42 20 72 61 79 | popular| DKB ray|
|000004a0| 74 72 61 63 65 72 20 76 | 65 72 73 69 6f 6e 20 32 |tracer v|ersion 2|
|000004b0| 2e 31 32 2e 0d 2a 20 44 | 4b 42 54 72 61 63 65 20 |.12..* D|KBTrace |
|000004c0| 77 61 73 20 6f 72 69 67 | 69 6e 61 6c 6c 79 20 77 |was orig|inally w|
|000004d0| 72 69 74 74 65 6e 20 62 | 79 20 44 61 76 69 64 20 |ritten b|y David |
|000004e0| 4b 2e 20 42 75 63 6b 2e | 0d 2a 20 44 4b 42 54 72 |K. Buck.|.* DKBTr|
|000004f0| 61 63 65 20 56 65 72 20 | 32 2e 30 2d 32 2e 31 32 |ace Ver |2.0-2.12|
|00000500| 20 77 65 72 65 20 77 72 | 69 74 74 65 6e 20 62 79 | were wr|itten by|
|00000510| 20 44 61 76 69 64 20 4b | 2e 20 42 75 63 6b 20 26 | David K|. Buck &|
|00000520| 20 41 61 72 6f 6e 20 41 | 2e 20 43 6f 6c 6c 69 6e | Aaron A|. Collin|
|00000530| 73 2e 0d 2a 0d 2a 2a 2a | 2a 2a 2a 2a 2a 2a 2a 2a |s..*.***|********|
|00000540| 2a 2a 2a 2a 2a 2a 2a 2a | 2a 2a 2a 2a 2a 2a 2a 2a |********|********|
|00000550| 2a 2a 2a 2a 2a 2a 2a 2a | 2a 2a 2a 2a 2a 2a 2a 2a |********|********|
|00000560| 2a 2a 2a 2a 2a 2a 2a 2a | 2a 2a 2a 2a 2a 2a 2a 2a |********|********|
|00000570| 2a 2a 2a 2a 2a 2a 2a 2a | 2a 2a 2a 2a 2a 2a 2a 2a |********|********|
|00000580| 2a 2a 2f 0d 0d 2f 2a 0d | 20 20 20 54 68 69 73 20 |**/../*.| This |
|00000590| 6d 6f 64 75 6c 65 20 77 | 61 73 20 66 72 65 65 6c |module w|as freel|
|000005a0| 79 20 62 6f 72 72 6f 77 | 65 64 20 66 72 6f 6d 20 |y borrow|ed from |
|000005b0| 46 52 41 43 54 49 4e 54 | 2c 20 73 6f 20 68 65 72 |FRACTINT|, so her|
|000005c0| 65 20 69 73 20 74 68 65 | 69 72 20 65 6e 74 69 72 |e is the|ir entir|
|000005d0| 65 0d 20 20 20 63 6f 70 | 79 72 69 67 68 74 20 74 |e. cop|yright t|
|000005e0| 6f 20 6b 65 65 70 20 74 | 68 65 6d 20 68 61 70 70 |o keep t|hem happ|
|000005f0| 79 3a 0d 2a 2f 0d 0d 2f | 2a 20 44 45 43 4f 44 45 |y:.*/../|* DECODE|
|00000600| 52 2e 43 20 2d 20 41 6e | 20 4c 5a 57 20 64 65 63 |R.C - An| LZW dec|
|00000610| 6f 64 65 72 20 66 6f 72 | 20 47 49 46 0d 20 2a 20 |oder for| GIF. * |
|00000620| 43 6f 70 79 72 69 67 68 | 74 20 28 43 29 20 31 39 |Copyrigh|t (C) 19|
|00000630| 38 37 2c 20 62 79 20 53 | 74 65 76 65 6e 20 41 2e |87, by S|teven A.|
|00000640| 20 42 65 6e 6e 65 74 74 | 0d 20 2a 0d 20 2a 20 50 | Bennett|. *. * P|
|00000650| 65 72 6d 69 73 73 69 6f | 6e 20 69 73 20 67 69 76 |ermissio|n is giv|
|00000660| 65 6e 20 62 79 20 74 68 | 65 20 61 75 74 68 6f 72 |en by th|e author|
|00000670| 20 74 6f 20 66 72 65 65 | 6c 79 20 72 65 64 69 73 | to free|ly redis|
|00000680| 74 72 69 62 75 74 65 20 | 61 6e 64 20 69 6e 63 6c |tribute |and incl|
|00000690| 75 64 65 0d 20 2a 20 74 | 68 69 73 20 63 6f 64 65 |ude. * t|his code|
|000006a0| 20 69 6e 20 61 6e 79 20 | 70 72 6f 67 72 61 6d 20 | in any |program |
|000006b0| 61 73 20 6c 6f 6e 67 20 | 61 73 20 74 68 69 73 20 |as long |as this |
|000006c0| 63 72 65 64 69 74 20 69 | 73 20 67 69 76 65 6e 20 |credit i|s given |
|000006d0| 77 68 65 72 65 20 64 75 | 65 2e 0d 20 2a 0d 20 2a |where du|e.. *. *|
|000006e0| 20 49 6e 20 61 63 63 6f | 72 64 61 6e 63 65 20 77 | In acco|rdance w|
|000006f0| 69 74 68 20 74 68 65 20 | 61 62 6f 76 65 2c 20 49 |ith the |above, I|
|00000700| 20 77 61 6e 74 20 74 6f | 20 63 72 65 64 69 74 20 | want to| credit |
|00000710| 53 74 65 76 65 20 57 69 | 6c 68 69 74 65 20 77 68 |Steve Wi|lhite wh|
|00000720| 6f 20 77 72 6f 74 65 0d | 20 2a 20 74 68 65 20 63 |o wrote.| * the c|
|00000730| 6f 64 65 20 77 68 69 63 | 68 20 74 68 69 73 20 69 |ode whic|h this i|
|00000740| 73 20 68 65 61 76 69 6c | 79 20 69 6e 73 70 69 72 |s heavil|y inspir|
|00000750| 65 64 20 62 79 2e 2e 2e | 0d 20 2a 0d 20 2a 20 47 |ed by...|. *. * G|
|00000760| 49 46 20 61 6e 64 20 27 | 47 72 61 70 68 69 63 73 |IF and '|Graphics|
|00000770| 20 49 6e 74 65 72 63 68 | 61 6e 67 65 20 46 6f 72 | Interch|ange For|
|00000780| 6d 61 74 27 20 61 72 65 | 20 74 72 61 64 65 6d 61 |mat' are| tradema|
|00000790| 72 6b 73 20 28 74 6d 29 | 20 6f 66 0d 20 2a 20 43 |rks (tm)| of. * C|
|000007a0| 6f 6d 70 75 73 65 72 76 | 65 2c 20 49 6e 63 6f 72 |ompuserv|e, Incor|
|000007b0| 70 6f 72 61 74 65 64 2c | 20 61 6e 20 48 26 52 20 |porated,| an H&R |
|000007c0| 42 6c 6f 63 6b 20 43 6f | 6d 70 61 6e 79 2e 0d 20 |Block Co|mpany.. |
|000007d0| 2a 0d 20 2a 20 52 65 6c | 65 61 73 65 20 4e 6f 74 |*. * Rel|ease Not|
|000007e0| 65 73 3a 20 54 68 69 73 | 20 66 69 6c 65 20 63 6f |es: This| file co|
|000007f0| 6e 74 61 69 6e 73 20 61 | 20 64 65 63 6f 64 65 72 |ntains a| decoder|
|00000800| 20 72 6f 75 74 69 6e 65 | 20 66 6f 72 20 47 49 46 | routine| for GIF|
|00000810| 20 69 6d 61 67 65 73 0d | 20 2a 20 77 68 69 63 68 | images.| * which|
|00000820| 20 69 73 20 73 69 6d 69 | 6c 61 72 2c 20 73 74 72 | is simi|lar, str|
|00000830| 75 63 74 75 72 61 6c 6c | 79 2c 20 74 6f 20 74 68 |ucturall|y, to th|
|00000840| 65 20 6f 72 69 67 69 6e | 61 6c 20 72 6f 75 74 69 |e origin|al routi|
|00000850| 6e 65 20 62 79 20 53 74 | 65 76 65 20 57 69 6c 68 |ne by St|eve Wilh|
|00000860| 69 74 65 2e 0d 20 2a 20 | 49 74 20 69 73 2c 20 68 |ite.. * |It is, h|
|00000870| 6f 77 65 76 65 72 2c 20 | 73 6f 6d 65 77 68 61 74 |owever, |somewhat|
|00000880| 20 6e 6f 74 69 63 61 62 | 6c 79 20 66 61 73 74 65 | noticab|ly faste|
|00000890| 72 20 69 6e 20 6d 6f 73 | 74 20 63 61 73 65 73 2e |r in mos|t cases.|
|000008a0| 0d 20 2a 0d 20 3d 3d 20 | 54 68 69 73 20 72 6f 75 |. *. == |This rou|
|000008b0| 74 69 6e 65 20 77 61 73 | 20 6d 6f 64 69 66 69 65 |tine was| modifie|
|000008c0| 64 20 66 6f 72 20 75 73 | 65 20 69 6e 20 46 52 41 |d for us|e in FRA|
|000008d0| 43 54 49 4e 54 20 69 6e | 20 74 77 6f 20 77 61 79 |CTINT in| two way|
|000008e0| 73 2e 0d 20 3d 3d 20 0d | 20 3d 3d 20 31 29 20 54 |s.. == .| == 1) T|
|000008f0| 68 65 20 6f 72 69 67 69 | 6e 61 6c 20 23 69 6e 63 |he origi|nal #inc|
|00000900| 6c 75 64 65 73 20 77 65 | 72 65 20 66 6f 6c 64 65 |ludes we|re folde|
|00000910| 64 20 69 6e 74 6f 20 74 | 68 65 20 72 6f 75 74 69 |d into t|he routi|
|00000920| 6e 65 20 73 74 72 69 63 | 74 6c 79 20 74 6f 20 68 |ne stric|tly to h|
|00000930| 6f 6c 64 0d 20 3d 3d 20 | 20 20 20 64 6f 77 6e 20 |old. == | down |
|00000940| 74 68 65 20 6e 75 6d 62 | 65 72 20 6f 66 20 66 69 |the numb|er of fi|
|00000950| 6c 65 73 20 77 65 20 77 | 65 72 65 20 64 65 61 6c |les we w|ere deal|
|00000960| 69 6e 67 20 77 69 74 68 | 2e 0d 20 3d 3d 0d 20 3d |ing with|.. ==. =|
|00000970| 3d 20 32 29 20 54 68 65 | 20 27 73 74 61 63 6b 27 |= 2) The| 'stack'|
|00000980| 2c 20 27 73 75 66 66 69 | 78 27 2c 20 27 70 72 65 |, 'suffi|x', 'pre|
|00000990| 66 69 78 27 2c 20 61 6e | 64 20 27 62 75 66 27 20 |fix', an|d 'buf' |
|000009a0| 61 72 72 61 79 73 20 77 | 65 72 65 20 63 68 61 6e |arrays w|ere chan|
|000009b0| 67 65 64 20 66 72 6f 6d | 0d 20 3d 3d 20 20 20 20 |ged from|. == |
|000009c0| 73 74 61 74 69 63 20 61 | 6e 64 20 27 6d 61 6c 6c |static a|nd 'mall|
|000009d0| 6f 63 28 29 27 65 64 20 | 74 6f 20 65 78 74 65 72 |oc()'ed |to exter|
|000009e0| 6e 61 6c 20 6f 6e 6c 79 | 20 73 6f 20 74 68 61 74 |nal only| so that|
|000009f0| 20 74 68 65 20 61 73 73 | 65 6d 62 6c 65 72 0d 20 | the ass|embler. |
|00000a00| 3d 3d 20 20 20 20 70 72 | 6f 67 72 61 6d 20 63 6f |== pr|ogram co|
|00000a10| 75 6c 64 20 75 73 65 20 | 74 68 65 20 73 61 6d 65 |uld use |the same|
|00000a20| 20 61 72 72 61 79 20 73 | 70 61 63 65 20 66 6f 72 | array s|pace for|
|00000a30| 20 73 65 76 65 72 61 6c | 20 69 6e 64 65 70 65 6e | several| indepen|
|00000a40| 64 65 6e 74 0d 20 3d 3d | 20 20 20 20 63 68 75 6e |dent. ==| chun|
|00000a50| 6b 73 20 6f 66 20 63 6f | 64 65 2e 20 20 41 6c 73 |ks of co|de. Als|
|00000a60| 6f 2c 20 27 73 74 61 63 | 6b 27 20 77 61 73 20 72 |o, 'stac|k' was r|
|00000a70| 65 6e 61 6d 65 64 20 74 | 6f 20 27 64 73 74 61 63 |enamed t|o 'dstac|
|00000a80| 6b 27 20 66 6f 72 20 54 | 41 53 4d 0d 20 3d 3d 20 |k' for T|ASM. == |
|00000a90| 20 20 20 63 6f 6d 70 61 | 74 69 62 69 6c 69 74 79 | compa|tibility|
|00000aa0| 2e 0d 20 3d 3d 20 0d 20 | 3d 3d 20 33 29 20 54 68 |.. == . |== 3) Th|
|00000ab0| 65 20 27 6f 75 74 5f 6c | 69 6e 65 28 29 27 20 65 |e 'out_l|ine()' e|
|00000ac0| 78 74 65 72 6e 61 6c 20 | 66 75 6e 63 74 69 6f 6e |xternal |function|
|00000ad0| 20 68 61 73 20 62 65 65 | 6e 20 63 68 61 6e 67 65 | has bee|n change|
|00000ae0| 64 20 74 6f 20 72 65 66 | 65 72 65 6e 63 65 20 0d |d to ref|erence .|
|00000af0| 20 3d 3d 20 20 20 20 27 | 2a 6f 75 74 6c 6e 28 29 | == '|*outln()|
|00000b00| 27 20 66 6f 72 20 66 6c | 65 78 69 62 69 6c 69 74 |' for fl|exibilit|
|00000b10| 79 20 28 69 6e 20 70 61 | 72 74 69 63 75 6c 61 72 |y (in pa|rticular|
|00000b20| 2c 20 33 44 20 74 72 61 | 6e 73 66 6f 72 6d 61 74 |, 3D tra|nsformat|
|00000b30| 69 6f 6e 73 29 0d 20 3d | 3d 0d 20 3d 3d 20 34 29 |ions). =|=. == 4)|
|00000b40| 20 41 20 63 61 6c 6c 20 | 74 6f 20 27 6b 65 79 70 | A call |to 'keyp|
|00000b50| 72 65 73 73 65 64 28 29 | 27 20 68 61 73 20 62 65 |ressed()|' has be|
|00000b60| 65 6e 20 61 64 64 65 64 | 20 61 66 74 65 72 20 74 |en added| after t|
|00000b70| 68 65 20 27 6f 75 74 6c | 6e 28 29 27 20 63 61 6c |he 'outl|n()' cal|
|00000b80| 6c 73 0d 20 3d 3d 20 20 | 20 20 74 6f 20 63 68 65 |ls. == | to che|
|00000b90| 63 6b 20 66 6f 72 20 74 | 68 65 20 70 72 65 73 65 |ck for t|he prese|
|00000ba0| 6e 63 20 6f 66 20 61 20 | 6b 65 79 2d 70 72 65 73 |nc of a |key-pres|
|00000bb0| 73 20 61 73 20 61 20 62 | 61 69 6c 2d 6f 75 74 20 |s as a b|ail-out |
|00000bc0| 73 69 67 6e 61 6c 0d 20 | 3d 3d 0d 20 3d 3d 20 28 |signal. |==. == (|
|00000bd0| 42 65 72 74 20 54 79 6c | 65 72 20 61 6e 64 20 54 |Bert Tyl|er and T|
|00000be0| 69 6d 6f 74 68 79 20 57 | 65 67 6e 65 72 29 0d 2a |imothy W|egner).*|
|00000bf0| 2f 0d 0d 2f 2a 20 0d 20 | 20 20 54 68 69 73 20 72 |/../* . | This r|
|00000c00| 6f 75 74 69 6e 65 20 77 | 61 73 20 6d 6f 64 69 66 |outine w|as modif|
|00000c10| 69 65 64 20 66 6f 72 20 | 50 65 72 73 69 73 74 65 |ied for |Persiste|
|00000c20| 6e 63 65 20 6f 66 20 56 | 69 73 69 6f 6e 20 52 61 |nce of V|ision Ra|
|00000c30| 79 74 72 61 63 65 72 20 | 69 6e 20 74 68 65 20 66 |ytracer |in the f|
|00000c40| 6f 6c 6c 6f 77 69 6e 67 | 20 77 61 79 73 3a 0d 0d |ollowing| ways:..|
|00000c50| 20 20 20 31 29 20 20 52 | 65 6d 6f 76 65 64 20 63 | 1) R|emoved c|
|00000c60| 61 6c 6c 73 20 74 6f 20 | 62 75 7a 7a 65 72 28 29 |alls to |buzzer()|
|00000c70| 20 61 6e 64 20 6b 65 79 | 70 72 65 73 73 65 64 28 | and key|pressed(|
|00000c80| 29 20 74 6f 20 67 65 74 | 20 72 69 64 20 6f 66 20 |) to get| rid of |
|00000c90| 41 53 4d 20 66 69 6c 65 | 73 2e 0d 0d 20 20 20 32 |ASM file|s... 2|
|00000ca0| 29 20 20 54 68 65 20 64 | 73 74 61 63 6b 2c 20 73 |) The d|stack, s|
|00000cb0| 75 66 66 69 78 2c 20 61 | 6e 64 20 70 72 65 66 69 |uffix, a|nd prefi|
|00000cc0| 78 20 61 72 72 61 79 73 | 20 77 65 72 65 20 6d 61 |x arrays| were ma|
|00000cd0| 64 65 20 53 54 41 54 49 | 43 20 6f 6e 63 65 20 61 |de STATI|C once a|
|00000ce0| 67 61 69 6e 2e 0d 0d 20 | 20 20 33 29 20 20 41 64 |gain... | 3) Ad|
|00000cf0| 64 65 64 20 74 68 65 20 | 75 73 75 61 6c 20 41 4e |ded the |usual AN|
|00000d00| 53 49 20 66 75 6e 63 74 | 69 6f 6e 20 70 72 6f 74 |SI funct|ion prot|
|00000d10| 6f 74 79 70 65 73 2c 20 | 65 74 63 2e 20 69 6e 20 |otypes, |etc. in |
|00000d20| 74 68 65 20 50 65 72 73 | 69 73 74 65 6e 63 65 20 |the Pers|istence |
|00000d30| 6f 66 20 56 69 73 69 6f | 6e 20 52 61 79 74 72 61 |of Visio|n Raytra|
|00000d40| 63 65 72 20 68 65 61 64 | 65 72 73 2e 0d 2a 2f 0d |cer head|ers..*/.|
|00000d50| 0d 23 69 6e 63 6c 75 64 | 65 20 22 66 72 61 6d 65 |.#includ|e "frame|
|00000d60| 2e 68 22 0d 23 69 6e 63 | 6c 75 64 65 20 22 70 6f |.h".#inc|lude "po|
|00000d70| 76 70 72 6f 74 6f 2e 68 | 22 0d 0d 23 64 65 66 69 |vproto.h|"..#defi|
|00000d80| 6e 65 20 4c 4f 43 41 4c | 20 73 74 61 74 69 63 0d |ne LOCAL| static.|
|00000d90| 23 64 65 66 69 6e 65 20 | 49 4d 50 4f 52 54 20 65 |#define |IMPORT e|
|00000da0| 78 74 65 72 6e 0d 0d 23 | 64 65 66 69 6e 65 20 46 |xtern..#|define F|
|00000db0| 41 53 54 20 72 65 67 69 | 73 74 65 72 0d 0d 2f 2a |AST regi|ster../*|
|00000dc0| 20 74 79 70 65 64 65 66 | 20 73 68 6f 72 74 20 57 | typedef| short W|
|00000dd0| 4f 52 44 3b 20 2a 2f 0d | 74 79 70 65 64 65 66 20 |ORD; */.|typedef |
|00000de0| 75 6e 73 69 67 6e 65 64 | 20 73 68 6f 72 74 20 55 |unsigned| short U|
|00000df0| 57 4f 52 44 3b 0d 74 79 | 70 65 64 65 66 20 63 68 |WORD;.ty|pedef ch|
|00000e00| 61 72 20 54 45 58 54 3b | 0d 74 79 70 65 64 65 66 |ar TEXT;|.typedef|
|00000e10| 20 75 6e 73 69 67 6e 65 | 64 20 63 68 61 72 20 55 | unsigne|d char U|
|00000e20| 54 49 4e 59 3b 0d 74 79 | 70 65 64 65 66 20 6c 6f |TINY;.ty|pedef lo|
|00000e30| 6e 67 20 4c 4f 4e 47 3b | 0d 74 79 70 65 64 65 66 |ng LONG;|.typedef|
|00000e40| 20 75 6e 73 69 67 6e 65 | 64 20 6c 6f 6e 67 20 55 | unsigne|d long U|
|00000e50| 4c 4f 4e 47 3b 0d 74 79 | 70 65 64 65 66 20 69 6e |LONG;.ty|pedef in|
|00000e60| 74 20 49 4e 54 3b 0d 0d | 0d 2f 2a 20 56 61 72 69 |t INT;..|./* Vari|
|00000e70| 6f 75 73 20 65 72 72 6f | 72 20 63 6f 64 65 73 20 |ous erro|r codes |
|00000e80| 75 73 65 64 20 62 79 20 | 64 65 63 6f 64 65 72 0d |used by |decoder.|
|00000e90| 20 2a 20 61 6e 64 20 6d | 79 20 6f 77 6e 20 72 6f | * and m|y own ro|
|00000ea0| 75 74 69 6e 65 73 2e 2e | 2e 20 20 20 49 74 27 73 |utines..|. It's|
|00000eb0| 20 6f 6b 61 79 0d 20 2a | 20 66 6f 72 20 79 6f 75 | okay. *| for you|
|00000ec0| 20 74 6f 20 64 65 66 69 | 6e 65 20 77 68 61 74 65 | to defi|ne whate|
|00000ed0| 76 65 72 20 79 6f 75 20 | 77 61 6e 74 2c 0d 20 2a |ver you |want,. *|
|00000ee0| 20 61 73 20 6c 6f 6e 67 | 20 61 73 20 69 74 27 73 | as long| as it's|
|00000ef0| 20 6e 65 67 61 74 69 76 | 65 2e 2e 2e 20 20 49 74 | negativ|e... It|
|00000f00| 20 77 69 6c 6c 20 62 65 | 0d 20 2a 20 72 65 74 75 | will be|. * retu|
|00000f10| 72 6e 65 64 20 69 6e 74 | 61 63 74 20 75 70 20 74 |rned int|act up t|
|00000f20| 68 65 20 76 61 72 69 6f | 75 73 20 73 75 62 72 6f |he vario|us subro|
|00000f30| 75 74 69 6e 65 0d 20 2a | 20 6c 65 76 65 6c 73 2e |utine. *| levels.|
|00000f40| 2e 2e 0d 20 2a 2f 0d 23 | 64 65 66 69 6e 65 20 4f |... */.#|define O|
|00000f50| 55 54 5f 4f 46 5f 4d 45 | 4d 4f 52 59 20 2d 31 30 |UT_OF_ME|MORY -10|
|00000f60| 0d 23 64 65 66 69 6e 65 | 20 42 41 44 5f 43 4f 44 |.#define| BAD_COD|
|00000f70| 45 5f 53 49 5a 45 20 2d | 32 30 0d 23 64 65 66 69 |E_SIZE -|20.#defi|
|00000f80| 6e 65 20 52 45 41 44 5f | 45 52 52 4f 52 20 2d 31 |ne READ_|ERROR -1|
|00000f90| 0d 23 64 65 66 69 6e 65 | 20 57 52 49 54 45 5f 45 |.#define| WRITE_E|
|00000fa0| 52 52 4f 52 20 2d 32 0d | 23 64 65 66 69 6e 65 20 |RROR -2.|#define |
|00000fb0| 4f 50 45 4e 5f 45 52 52 | 4f 52 20 2d 33 0d 23 64 |OPEN_ERR|OR -3.#d|
|00000fc0| 65 66 69 6e 65 20 43 52 | 45 41 54 45 5f 45 52 52 |efine CR|EATE_ERR|
|00000fd0| 4f 52 20 2d 34 0d 0d 0d | 2f 2a 20 49 4d 50 4f 52 |OR -4...|/* IMPOR|
|00000fe0| 54 20 49 4e 54 20 67 65 | 74 5f 62 79 74 65 28 29 |T INT ge|t_byte()|
|00000ff0| 0d 20 2a 0d 20 2a 20 20 | 20 2d 20 54 68 69 73 20 |. *. * | - This |
|00001000| 65 78 74 65 72 6e 61 6c | 20 28 6d 61 63 68 69 6e |external| (machin|
|00001010| 65 20 73 70 65 63 69 66 | 69 63 29 20 66 75 6e 63 |e specif|ic) func|
|00001020| 74 69 6f 6e 20 69 73 20 | 65 78 70 65 63 74 65 64 |tion is |expected|
|00001030| 20 74 6f 20 72 65 74 75 | 72 6e 0d 20 2a 20 65 69 | to retu|rn. * ei|
|00001040| 74 68 65 72 20 74 68 65 | 20 6e 65 78 74 20 62 79 |ther the| next by|
|00001050| 74 65 20 66 72 6f 6d 20 | 74 68 65 20 47 49 46 20 |te from |the GIF |
|00001060| 66 69 6c 65 2c 20 6f 72 | 20 61 20 6e 65 67 61 74 |file, or| a negat|
|00001070| 69 76 65 20 6e 75 6d 62 | 65 72 2c 20 61 73 0d 20 |ive numb|er, as. |
|00001080| 2a 20 64 65 66 69 6e 65 | 64 20 69 6e 20 45 52 52 |* define|d in ERR|
|00001090| 53 2e 48 2e 0d 20 2a 2f | 0d 49 4d 50 4f 52 54 20 |S.H.. */|.IMPORT |
|000010a0| 49 4e 54 20 67 65 74 5f | 62 79 74 65 28 29 3b 0d |INT get_|byte();.|
|000010b0| 0d 2f 2a 20 49 4d 50 4f | 52 54 20 49 4e 54 20 6f |./* IMPO|RT INT o|
|000010c0| 75 74 5f 6c 69 6e 65 28 | 70 69 78 65 6c 73 2c 20 |ut_line(|pixels, |
|000010d0| 6c 69 6e 65 6c 65 6e 29 | 0d 20 2a 20 20 20 20 20 |linelen)|. * |
|000010e0| 55 42 59 54 45 20 70 69 | 78 65 6c 73 5b 5d 3b 0d |UBYTE pi|xels[];.|
|000010f0| 20 2a 20 20 20 20 20 49 | 4e 54 20 6c 69 6e 65 6c | * I|NT linel|
|00001100| 65 6e 3b 0d 20 2a 0d 20 | 2a 20 20 20 2d 20 54 68 |en;. *. |* - Th|
|00001110| 69 73 20 66 75 6e 63 74 | 69 6f 6e 20 74 61 6b 65 |is funct|ion take|
|00001120| 73 20 61 20 66 75 6c 6c | 20 6c 69 6e 65 20 6f 66 |s a full| line of|
|00001130| 20 70 69 78 65 6c 73 20 | 28 6f 6e 65 20 62 79 74 | pixels |(one byt|
|00001140| 65 20 70 65 72 20 70 69 | 78 65 6c 29 20 61 6e 64 |e per pi|xel) and|
|00001150| 0d 20 2a 20 64 69 73 70 | 6c 61 79 73 20 74 68 65 |. * disp|lays the|
|00001160| 6d 20 28 6f 72 20 64 6f | 65 73 20 77 68 61 74 65 |m (or do|es whate|
|00001170| 76 65 72 20 79 6f 75 72 | 20 70 72 6f 67 72 61 6d |ver your| program|
|00001180| 20 77 61 6e 74 73 20 77 | 69 74 68 20 74 68 65 6d | wants w|ith them|
|00001190| 2e 2e 2e 29 2e 20 20 49 | 74 0d 20 2a 20 73 68 6f |...). I|t. * sho|
|000011a0| 75 6c 64 20 72 65 74 75 | 72 6e 20 7a 65 72 6f 2c |uld retu|rn zero,|
|000011b0| 20 6f 72 20 6e 65 67 61 | 74 69 76 65 20 69 66 20 | or nega|tive if |
|000011c0| 61 6e 20 65 72 72 6f 72 | 20 6f 72 20 73 6f 6d 65 |an error| or some|
|000011d0| 20 6f 74 68 65 72 20 65 | 76 65 6e 74 20 6f 63 63 | other e|vent occ|
|000011e0| 75 72 73 0d 20 2a 20 77 | 68 69 63 68 20 77 6f 75 |urs. * w|hich wou|
|000011f0| 6c 64 20 72 65 71 75 69 | 72 65 20 61 62 6f 72 74 |ld requi|re abort|
|00001200| 69 6e 67 20 74 68 65 20 | 64 65 63 6f 64 65 20 70 |ing the |decode p|
|00001210| 72 6f 63 65 73 73 2e 2e | 2e 20 20 4e 6f 74 65 20 |rocess..|. Note |
|00001220| 74 68 61 74 20 74 68 65 | 20 6c 65 6e 67 74 68 0d |that the| length.|
|00001230| 20 2a 20 70 61 73 73 65 | 64 20 77 69 6c 6c 20 61 | * passe|d will a|
|00001240| 6c 6d 6f 73 74 20 61 6c | 77 61 79 73 20 62 65 20 |lmost al|ways be |
|00001250| 65 71 75 61 6c 20 74 6f | 20 74 68 65 20 6c 69 6e |equal to| the lin|
|00001260| 65 20 6c 65 6e 67 74 68 | 20 70 61 73 73 65 64 20 |e length| passed |
|00001270| 74 6f 20 74 68 65 0d 20 | 2a 20 64 65 63 6f 64 65 |to the. |* decode|
|00001280| 72 20 66 75 6e 63 74 69 | 6f 6e 2c 20 77 69 74 68 |r functi|on, with|
|00001290| 20 74 68 65 20 73 6f 6c | 65 20 65 78 63 65 70 74 | the sol|e except|
|000012a0| 69 6f 6e 20 6f 63 63 75 | 72 72 69 6e 67 20 77 68 |ion occu|rring wh|
|000012b0| 65 6e 20 61 6e 20 65 6e | 64 69 6e 67 20 63 6f 64 |en an en|ding cod|
|000012c0| 65 0d 20 2a 20 6f 63 63 | 75 72 73 20 69 6e 20 61 |e. * occ|urs in a|
|000012d0| 6e 20 6f 64 64 20 70 6c | 61 63 65 20 69 6e 20 74 |n odd pl|ace in t|
|000012e0| 68 65 20 47 49 46 20 66 | 69 6c 65 2e 2e 2e 20 20 |he GIF f|ile... |
|000012f0| 49 6e 20 61 6e 79 20 63 | 61 73 65 2c 20 6c 69 6e |In any c|ase, lin|
|00001300| 65 6c 65 6e 20 77 69 6c | 6c 20 62 65 0d 20 2a 20 |elen wil|l be. * |
|00001310| 65 71 75 61 6c 20 74 6f | 20 74 68 65 20 6e 75 6d |equal to| the num|
|00001320| 62 65 72 20 6f 66 20 70 | 69 78 65 6c 73 20 70 61 |ber of p|ixels pa|
|00001330| 73 73 65 64 2e 2e 2e 0d | 20 2a 2f 0d 49 4d 50 4f |ssed....| */.IMPO|
|00001340| 52 54 20 49 4e 54 20 6f | 75 74 5f 6c 69 6e 65 28 |RT INT o|ut_line(|
|00001350| 29 3b 0d 0d 2f 2a 20 49 | 4d 50 4f 52 54 20 49 4e |);../* I|MPORT IN|
|00001360| 54 20 62 61 64 5f 63 6f | 64 65 5f 63 6f 75 6e 74 |T bad_co|de_count|
|00001370| 3b 0d 20 2a 0d 20 2a 20 | 54 68 69 73 20 76 61 6c |;. *. * |This val|
|00001380| 75 65 20 69 73 20 74 68 | 65 20 6f 6e 6c 79 20 6f |ue is th|e only o|
|00001390| 74 68 65 72 20 67 6c 6f | 62 61 6c 20 72 65 71 75 |ther glo|bal requ|
|000013a0| 69 72 65 64 20 62 79 20 | 74 68 65 20 75 73 69 6e |ired by |the usin|
|000013b0| 67 20 70 72 6f 67 72 61 | 6d 2c 20 61 6e 64 0d 20 |g progra|m, and. |
|000013c0| 2a 20 69 73 20 69 6e 63 | 72 65 6d 65 6e 74 65 64 |* is inc|remented|
|000013d0| 20 65 61 63 68 20 74 69 | 6d 65 20 61 6e 20 6f 75 | each ti|me an ou|
|000013e0| 74 20 6f 66 20 72 61 6e | 67 65 20 63 6f 64 65 20 |t of ran|ge code |
|000013f0| 69 73 20 72 65 61 64 20 | 62 79 20 74 68 65 20 64 |is read |by the d|
|00001400| 65 63 6f 64 65 72 2e 0d | 20 2a 20 57 68 65 6e 20 |ecoder..| * When |
|00001410| 74 68 69 73 20 76 61 6c | 75 65 20 69 73 20 6e 6f |this val|ue is no|
|00001420| 6e 2d 7a 65 72 6f 20 61 | 66 74 65 72 20 61 20 64 |n-zero a|fter a d|
|00001430| 65 63 6f 64 65 2c 20 79 | 6f 75 72 20 47 49 46 20 |ecode, y|our GIF |
|00001440| 66 69 6c 65 20 69 73 20 | 70 72 6f 62 61 62 6c 79 |file is |probably|
|00001450| 0d 20 2a 20 63 6f 72 72 | 75 70 74 20 69 6e 20 73 |. * corr|upt in s|
|00001460| 6f 6d 65 20 77 61 79 2e | 2e 2e 0d 20 2a 2f 0d 49 |ome way.|... */.I|
|00001470| 4e 54 20 62 61 64 5f 63 | 6f 64 65 5f 63 6f 75 6e |NT bad_c|ode_coun|
|00001480| 74 3b 0d 0d 23 64 65 66 | 69 6e 65 20 4d 41 58 5f |t;..#def|ine MAX_|
|00001490| 43 4f 44 45 53 20 20 20 | 34 30 39 35 0d 0d 2f 2a |CODES |4095../*|
|000014a0| 20 53 74 61 74 69 63 20 | 76 61 72 69 61 62 6c 65 | Static |variable|
|000014b0| 73 20 2a 2f 0d 4c 4f 43 | 41 4c 20 57 4f 52 44 20 |s */.LOC|AL WORD |
|000014c0| 63 75 72 72 5f 73 69 7a | 65 3b 20 20 20 20 20 20 |curr_siz|e; |
|000014d0| 20 20 20 20 20 20 20 20 | 20 20 20 20 20 20 20 2f | | /|
|000014e0| 2a 20 54 68 65 20 63 75 | 72 72 65 6e 74 20 63 6f |* The cu|rrent co|
|000014f0| 64 65 20 73 69 7a 65 20 | 2a 2f 0d 4c 4f 43 41 4c |de size |*/.LOCAL|
|00001500| 20 57 4f 52 44 20 63 6c | 65 61 72 3b 20 20 20 20 | WORD cl|ear; |
|00001510| 20 20 20 20 20 20 20 20 | 20 20 20 20 20 20 20 20 | | |
|00001520| 20 20 20 20 20 2f 2a 20 | 56 61 6c 75 65 20 66 6f | /* |Value fo|
|00001530| 72 20 61 20 63 6c 65 61 | 72 20 63 6f 64 65 20 2a |r a clea|r code *|
|00001540| 2f 0d 4c 4f 43 41 4c 20 | 57 4f 52 44 20 65 6e 64 |/.LOCAL |WORD end|
|00001550| 69 6e 67 3b 20 20 20 20 | 20 20 20 20 20 20 20 20 |ing; | |
|00001560| 20 20 20 20 20 20 20 20 | 20 20 20 20 2f 2a 20 56 | | /* V|
|00001570| 61 6c 75 65 20 66 6f 72 | 20 61 20 65 6e 64 69 6e |alue for| a endin|
|00001580| 67 20 63 6f 64 65 20 2a | 2f 0d 4c 4f 43 41 4c 20 |g code *|/.LOCAL |
|00001590| 57 4f 52 44 20 6e 65 77 | 63 6f 64 65 73 3b 20 20 |WORD new|codes; |
|000015a0| 20 20 20 20 20 20 20 20 | 20 20 20 20 20 20 20 20 | | |
|000015b0| 20 20 20 20 2f 2a 20 46 | 69 72 73 74 20 61 76 61 | /* F|irst ava|
|000015c0| 69 6c 61 62 6c 65 20 63 | 6f 64 65 20 2a 2f 0d 4c |ilable c|ode */.L|
|000015d0| 4f 43 41 4c 20 57 4f 52 | 44 20 74 6f 70 5f 73 6c |OCAL WOR|D top_sl|
|000015e0| 6f 74 3b 20 20 20 20 20 | 20 20 20 20 20 20 20 20 |ot; | |
|000015f0| 20 20 20 20 20 20 20 20 | 20 2f 2a 20 48 69 67 68 | | /* High|
|00001600| 65 73 74 20 63 6f 64 65 | 20 66 6f 72 20 63 75 72 |est code| for cur|
|00001610| 72 65 6e 74 20 73 69 7a | 65 20 2a 2f 0d 4c 4f 43 |rent siz|e */.LOC|
|00001620| 41 4c 20 57 4f 52 44 20 | 73 6c 6f 74 3b 20 20 20 |AL WORD |slot; |
|00001630| 20 20 20 20 20 20 20 20 | 20 20 20 20 20 20 20 20 | | |
|00001640| 20 20 20 20 20 20 20 2f | 2a 20 4c 61 73 74 20 72 | /|* Last r|
|00001650| 65 61 64 20 63 6f 64 65 | 20 2a 2f 0d 0d 2f 2a 20 |ead code| */../* |
|00001660| 54 68 65 20 66 6f 6c 6c | 6f 77 69 6e 67 20 73 74 |The foll|owing st|
|00001670| 61 74 69 63 20 76 61 72 | 69 61 62 6c 65 73 20 61 |atic var|iables a|
|00001680| 72 65 20 75 73 65 64 0d | 20 2a 20 66 6f 72 20 73 |re used.| * for s|
|00001690| 65 70 65 72 61 74 69 6e | 67 20 6f 75 74 20 63 6f |eperatin|g out co|
|000016a0| 64 65 73 0d 20 2a 2f 0d | 4c 4f 43 41 4c 20 57 4f |des. */.|LOCAL WO|
|000016b0| 52 44 20 6e 61 76 61 69 | 6c 5f 62 79 74 65 73 20 |RD navai|l_bytes |
|000016c0| 3d 20 30 3b 20 20 20 20 | 20 20 20 20 20 20 20 20 |= 0; | |
|000016d0| 20 20 2f 2a 20 23 20 62 | 79 74 65 73 20 6c 65 66 | /* # b|ytes lef|
|000016e0| 74 20 69 6e 20 62 6c 6f | 63 6b 20 2a 2f 0d 4c 4f |t in blo|ck */.LO|
|000016f0| 43 41 4c 20 57 4f 52 44 | 20 6e 62 69 74 73 5f 6c |CAL WORD| nbits_l|
|00001700| 65 66 74 20 3d 20 30 3b | 20 20 20 20 20 20 20 20 |eft = 0;| |
|00001710| 20 20 20 20 20 20 20 20 | 2f 2a 20 23 20 62 69 74 | |/* # bit|
|00001720| 73 20 6c 65 66 74 20 69 | 6e 20 63 75 72 72 65 6e |s left i|n curren|
|00001730| 74 20 62 79 74 65 20 2a | 2f 0d 4c 4f 43 41 4c 20 |t byte *|/.LOCAL |
|00001740| 55 54 49 4e 59 20 62 31 | 3b 20 20 20 20 20 20 20 |UTINY b1|; |
|00001750| 20 20 20 20 20 20 20 20 | 20 20 20 20 20 20 20 20 | | |
|00001760| 20 20 20 20 2f 2a 20 43 | 75 72 72 65 6e 74 20 62 | /* C|urrent b|
|00001770| 79 74 65 20 2a 2f 0d 4c | 4f 43 41 4c 20 55 54 49 |yte */.L|OCAL UTI|
|00001780| 4e 59 20 62 79 74 65 5f | 62 75 66 66 5b 32 35 37 |NY byte_|buff[257|
|00001790| 5d 3b 20 20 20 20 20 20 | 20 20 20 20 20 20 20 20 |]; | |
|000017a0| 20 2f 2a 20 43 75 72 72 | 65 6e 74 20 62 6c 6f 63 | /* Curr|ent bloc|
|000017b0| 6b 20 2a 2f 0d 4c 4f 43 | 41 4c 20 55 54 49 4e 59 |k */.LOC|AL UTINY|
|000017c0| 20 2a 70 62 79 74 65 73 | 3b 20 20 20 20 20 20 20 | *pbytes|; |
|000017d0| 20 20 20 20 20 20 20 20 | 20 20 20 20 20 20 20 2f | | /|
|000017e0| 2a 20 50 6f 69 6e 74 65 | 72 20 74 6f 20 6e 65 78 |* Pointe|r to nex|
|000017f0| 74 20 62 79 74 65 20 69 | 6e 20 62 6c 6f 63 6b 20 |t byte i|n block |
|00001800| 2a 2f 0d 0d 20 20 4c 4f | 43 41 4c 20 4c 4f 4e 47 |*/.. LO|CAL LONG|
|00001810| 20 63 6f 64 65 5f 6d 61 | 73 6b 5b 31 33 5d 20 3d | code_ma|sk[13] =|
|00001820| 20 7b 0d 20 20 30 2c 0d | 20 20 30 78 30 30 30 31 | {. 0,.| 0x0001|
|00001830| 2c 20 30 78 30 30 30 33 | 2c 0d 20 20 30 78 30 30 |, 0x0003|,. 0x00|
|00001840| 30 37 2c 20 30 78 30 30 | 30 46 2c 0d 20 20 30 78 |07, 0x00|0F,. 0x|
|00001850| 30 30 31 46 2c 20 30 78 | 30 30 33 46 2c 0d 20 20 |001F, 0x|003F,. |
|00001860| 30 78 30 30 37 46 2c 20 | 30 78 30 30 46 46 2c 0d |0x007F, |0x00FF,.|
|00001870| 20 20 30 78 30 31 46 46 | 2c 20 30 78 30 33 46 46 | 0x01FF|, 0x03FF|
|00001880| 2c 0d 20 20 30 78 30 37 | 46 46 2c 20 30 78 30 46 |,. 0x07|FF, 0x0F|
|00001890| 46 46 0d 20 20 7d 3b 0d | 0d 0d 2f 2a 20 54 68 69 |FF. };.|../* Thi|
|000018a0| 73 20 66 75 6e 63 74 69 | 6f 6e 20 69 6e 69 74 69 |s functi|on initi|
|000018b0| 61 6c 69 7a 65 73 20 74 | 68 65 20 64 65 63 6f 64 |alizes t|he decod|
|000018c0| 65 72 20 66 6f 72 20 72 | 65 61 64 69 6e 67 20 61 |er for r|eading a|
|000018d0| 20 6e 65 77 20 69 6d 61 | 67 65 2e 0d 20 2a 2f 0d | new ima|ge.. */.|
|000018e0| 57 4f 52 44 20 69 6e 69 | 74 5f 65 78 70 20 28 69 |WORD ini|t_exp (i|
|000018f0| 5f 73 69 7a 65 29 0d 69 | 6e 74 20 69 5f 73 69 7a |_size).i|nt i_siz|
|00001900| 65 3b 0d 20 20 7b 0d 20 | 20 57 4f 52 44 20 73 69 |e;. {. | WORD si|
|00001910| 7a 65 3b 0d 20 20 73 69 | 7a 65 20 3d 20 28 57 4f |ze;. si|ze = (WO|
|00001920| 52 44 29 69 5f 73 69 7a | 65 3b 0d 20 20 63 75 72 |RD)i_siz|e;. cur|
|00001930| 72 5f 73 69 7a 65 20 3d | 20 73 69 7a 65 20 2b 20 |r_size =| size + |
|00001940| 31 3b 0d 20 20 74 6f 70 | 5f 73 6c 6f 74 20 3d 20 |1;. top|_slot = |
|00001950| 31 20 3c 3c 20 63 75 72 | 72 5f 73 69 7a 65 3b 0d |1 << cur|r_size;.|
|00001960| 20 20 63 6c 65 61 72 20 | 3d 20 31 20 3c 3c 20 73 | clear |= 1 << s|
|00001970| 69 7a 65 3b 0d 20 20 65 | 6e 64 69 6e 67 20 3d 20 |ize;. e|nding = |
|00001980| 63 6c 65 61 72 20 2b 20 | 31 3b 0d 20 20 73 6c 6f |clear + |1;. slo|
|00001990| 74 20 3d 20 6e 65 77 63 | 6f 64 65 73 20 3d 20 65 |t = newc|odes = e|
|000019a0| 6e 64 69 6e 67 20 2b 20 | 31 3b 0d 20 20 6e 61 76 |nding + |1;. nav|
|000019b0| 61 69 6c 5f 62 79 74 65 | 73 20 3d 20 6e 62 69 74 |ail_byte|s = nbit|
|000019c0| 73 5f 6c 65 66 74 20 3d | 20 30 3b 0d 20 20 72 65 |s_left =| 0;. re|
|000019d0| 74 75 72 6e 28 30 29 3b | 0d 20 20 7d 0d 0d 2f 2a |turn(0);|. }../*|
|000019e0| 20 67 65 74 5f 6e 65 78 | 74 5f 63 6f 64 65 28 29 | get_nex|t_code()|
|000019f0| 0d 20 2a 20 2d 20 67 65 | 74 73 20 74 68 65 20 6e |. * - ge|ts the n|
|00001a00| 65 78 74 20 63 6f 64 65 | 20 66 72 6f 6d 20 74 68 |ext code| from th|
|00001a10| 65 20 47 49 46 20 66 69 | 6c 65 2e 20 20 52 65 74 |e GIF fi|le. Ret|
|00001a20| 75 72 6e 73 20 74 68 65 | 20 63 6f 64 65 2c 20 6f |urns the| code, o|
|00001a30| 72 20 65 6c 73 65 0d 20 | 2a 20 61 20 6e 65 67 61 |r else. |* a nega|
|00001a40| 74 69 76 65 20 6e 75 6d | 62 65 72 20 69 6e 20 63 |tive num|ber in c|
|00001a50| 61 73 65 20 6f 66 20 66 | 69 6c 65 20 65 72 72 6f |ase of f|ile erro|
|00001a60| 72 73 2e 2e 2e 0d 20 2a | 2f 0d 57 4f 52 44 20 67 |rs.... *|/.WORD g|
|00001a70| 65 74 5f 6e 65 78 74 5f | 63 6f 64 65 28 29 0d 20 |et_next_|code(). |
|00001a80| 20 7b 0d 20 20 57 4f 52 | 44 20 69 2c 20 78 3b 0d | {. WOR|D i, x;.|
|00001a90| 20 20 55 4c 4f 4e 47 20 | 72 65 74 3b 0d 0d 20 20 | ULONG |ret;.. |
|00001aa0| 69 66 20 28 6e 62 69 74 | 73 5f 6c 65 66 74 20 3d |if (nbit|s_left =|
|00001ab0| 3d 20 30 29 0d 20 20 20 | 20 7b 0d 20 20 20 20 69 |= 0). | {. i|
|00001ac0| 66 20 28 6e 61 76 61 69 | 6c 5f 62 79 74 65 73 20 |f (navai|l_bytes |
|00001ad0| 3c 3d 20 30 29 0d 20 20 | 20 20 20 20 7b 0d 0d 20 |<= 0). | {.. |
|00001ae0| 20 20 20 20 20 2f 2a 20 | 4f 75 74 20 6f 66 20 62 | /* |Out of b|
|00001af0| 79 74 65 73 20 69 6e 20 | 63 75 72 72 65 6e 74 20 |ytes in |current |
|00001b00| 62 6c 6f 63 6b 2c 20 73 | 6f 20 72 65 61 64 20 6e |block, s|o read n|
|00001b10| 65 78 74 20 62 6c 6f 63 | 6b 0d 20 20 20 20 20 20 |ext bloc|k. |
|00001b20| 20 20 20 20 2a 2f 0d 20 | 20 20 20 20 20 70 62 79 | */. | pby|
|00001b30| 74 65 73 20 3d 20 62 79 | 74 65 5f 62 75 66 66 3b |tes = by|te_buff;|
|00001b40| 0d 20 20 20 20 20 20 69 | 66 20 28 28 6e 61 76 61 |. i|f ((nava|
|00001b50| 69 6c 5f 62 79 74 65 73 | 20 3d 20 67 65 74 5f 62 |il_bytes| = get_b|
|00001b60| 79 74 65 28 29 29 20 3c | 20 30 29 0d 20 20 20 20 |yte()) <| 0). |
|00001b70| 20 20 20 20 72 65 74 75 | 72 6e 28 6e 61 76 61 69 | retu|rn(navai|
|00001b80| 6c 5f 62 79 74 65 73 29 | 3b 0d 20 20 20 20 20 20 |l_bytes)|;. |
|00001b90| 65 6c 73 65 20 69 66 20 | 28 6e 61 76 61 69 6c 5f |else if |(navail_|
|00001ba0| 62 79 74 65 73 29 0d 20 | 20 20 20 20 20 20 20 7b |bytes). | {|
|00001bb0| 0d 20 20 20 20 20 20 20 | 20 66 6f 72 20 28 69 20 |. | for (i |
|00001bc0| 3d 20 30 3b 20 69 20 3c | 20 6e 61 76 61 69 6c 5f |= 0; i <| navail_|
|00001bd0| 62 79 74 65 73 3b 20 2b | 2b 69 29 0d 20 20 20 20 |bytes; +|+i). |
|00001be0| 20 20 20 20 20 20 7b 0d | 20 20 20 20 20 20 20 20 | {.| |
|00001bf0| 20 20 69 66 20 28 28 78 | 20 3d 20 67 65 74 5f 62 | if ((x| = get_b|
|00001c00| 79 74 65 28 29 29 20 3c | 20 30 29 0d 20 20 20 20 |yte()) <| 0). |
|00001c10| 20 20 20 20 20 20 20 20 | 72 65 74 75 72 6e 28 78 | |return(x|
|00001c20| 29 3b 0d 20 20 20 20 20 | 20 20 20 20 20 62 79 74 |);. | byt|
|00001c30| 65 5f 62 75 66 66 5b 69 | 5d 20 3d 20 28 55 54 49 |e_buff[i|] = (UTI|
|00001c40| 4e 59 29 20 78 3b 0d 20 | 20 20 20 20 20 20 20 20 |NY) x;. | |
|00001c50| 20 7d 0d 20 20 20 20 20 | 20 20 20 7d 0d 20 20 20 | }. | }. |
|00001c60| 20 20 20 7d 0d 20 20 20 | 20 62 31 20 3d 20 2a 70 | }. | b1 = *p|
|00001c70| 62 79 74 65 73 2b 2b 3b | 0d 20 20 20 20 6e 62 69 |bytes++;|. nbi|
|00001c80| 74 73 5f 6c 65 66 74 20 | 3d 20 38 3b 0d 20 20 20 |ts_left |= 8;. |
|00001c90| 20 2d 2d 6e 61 76 61 69 | 6c 5f 62 79 74 65 73 3b | --navai|l_bytes;|
|00001ca0| 0d 20 20 20 20 7d 0d 0d | 20 20 72 65 74 20 3d 20 |. }..| ret = |
|00001cb0| 62 31 20 3e 3e 20 28 38 | 20 2d 20 6e 62 69 74 73 |b1 >> (8| - nbits|
|00001cc0| 5f 6c 65 66 74 29 3b 0d | 20 20 77 68 69 6c 65 20 |_left);.| while |
|00001cd0| 28 63 75 72 72 5f 73 69 | 7a 65 20 3e 20 6e 62 69 |(curr_si|ze > nbi|
|00001ce0| 74 73 5f 6c 65 66 74 29 | 0d 20 20 20 20 7b 0d 20 |ts_left)|. {. |
|00001cf0| 20 20 20 69 66 20 28 6e | 61 76 61 69 6c 5f 62 79 | if (n|avail_by|
|00001d00| 74 65 73 20 3c 3d 20 30 | 29 0d 20 20 20 20 20 20 |tes <= 0|). |
|00001d10| 7b 0d 0d 20 20 20 20 20 | 20 2f 2a 20 4f 75 74 20 |{.. | /* Out |
|00001d20| 6f 66 20 62 79 74 65 73 | 20 69 6e 20 63 75 72 72 |of bytes| in curr|
|00001d30| 65 6e 74 20 62 6c 6f 63 | 6b 2c 20 73 6f 20 72 65 |ent bloc|k, so re|
|00001d40| 61 64 20 6e 65 78 74 20 | 62 6c 6f 63 6b 0d 20 20 |ad next |block. |
|00001d50| 20 20 20 20 20 20 20 20 | 2a 2f 0d 20 20 20 20 20 | |*/. |
|00001d60| 20 70 62 79 74 65 73 20 | 3d 20 62 79 74 65 5f 62 | pbytes |= byte_b|
|00001d70| 75 66 66 3b 0d 20 20 20 | 20 20 20 69 66 20 28 28 |uff;. | if ((|
|00001d80| 6e 61 76 61 69 6c 5f 62 | 79 74 65 73 20 3d 20 67 |navail_b|ytes = g|
|00001d90| 65 74 5f 62 79 74 65 28 | 29 29 20 3c 20 30 29 0d |et_byte(|)) < 0).|
|00001da0| 20 20 20 20 20 20 20 20 | 72 65 74 75 72 6e 28 6e | |return(n|
|00001db0| 61 76 61 69 6c 5f 62 79 | 74 65 73 29 3b 0d 20 20 |avail_by|tes);. |
|00001dc0| 20 20 20 20 65 6c 73 65 | 20 69 66 20 28 6e 61 76 | else| if (nav|
|00001dd0| 61 69 6c 5f 62 79 74 65 | 73 29 0d 20 20 20 20 20 |ail_byte|s). |
|00001de0| 20 20 20 7b 0d 20 20 20 | 20 20 20 20 20 66 6f 72 | {. | for|
|00001df0| 20 28 69 20 3d 20 30 3b | 20 69 20 3c 20 6e 61 76 | (i = 0;| i < nav|
|00001e00| 61 69 6c 5f 62 79 74 65 | 73 3b 20 2b 2b 69 29 0d |ail_byte|s; ++i).|
|00001e10| 20 20 20 20 20 20 20 20 | 20 20 7b 0d 20 20 20 20 | | {. |
|00001e20| 20 20 20 20 20 20 69 66 | 20 28 28 78 20 3d 20 67 | if| ((x = g|
|00001e30| 65 74 5f 62 79 74 65 28 | 29 29 20 3c 20 30 29 0d |et_byte(|)) < 0).|
|00001e40| 20 20 20 20 20 20 20 20 | 20 20 20 20 72 65 74 75 | | retu|
|00001e50| 72 6e 28 78 29 3b 0d 20 | 20 20 20 20 20 20 20 20 |rn(x);. | |
|00001e60| 20 62 79 74 65 5f 62 75 | 66 66 5b 69 5d 20 3d 20 | byte_bu|ff[i] = |
|00001e70| 28 55 54 49 4e 59 29 20 | 78 3b 0d 20 20 20 20 20 |(UTINY) |x;. |
|00001e80| 20 20 20 20 20 7d 0d 20 | 20 20 20 20 20 20 20 7d | }. | }|
|00001e90| 0d 20 20 20 20 20 20 7d | 0d 20 20 20 20 62 31 20 |. }|. b1 |
|00001ea0| 3d 20 2a 70 62 79 74 65 | 73 2b 2b 3b 0d 20 20 20 |= *pbyte|s++;. |
|00001eb0| 20 72 65 74 20 7c 3d 20 | 62 31 20 3c 3c 20 6e 62 | ret |= |b1 << nb|
|00001ec0| 69 74 73 5f 6c 65 66 74 | 3b 0d 20 20 20 20 6e 62 |its_left|;. nb|
|00001ed0| 69 74 73 5f 6c 65 66 74 | 20 2b 3d 20 38 3b 0d 20 |its_left| += 8;. |
|00001ee0| 20 20 20 2d 2d 6e 61 76 | 61 69 6c 5f 62 79 74 65 | --nav|ail_byte|
|00001ef0| 73 3b 0d 20 20 20 20 7d | 0d 20 20 6e 62 69 74 73 |s;. }|. nbits|
|00001f00| 5f 6c 65 66 74 20 2d 3d | 20 63 75 72 72 5f 73 69 |_left -=| curr_si|
|00001f10| 7a 65 3b 0d 20 20 72 65 | 74 20 26 3d 20 63 6f 64 |ze;. re|t &= cod|
|00001f20| 65 5f 6d 61 73 6b 5b 63 | 75 72 72 5f 73 69 7a 65 |e_mask[c|urr_size|
|00001f30| 5d 3b 0d 20 20 72 65 74 | 75 72 6e 28 28 57 4f 52 |];. ret|urn((WOR|
|00001f40| 44 29 28 72 65 74 29 29 | 3b 0d 20 20 7d 0d 0d 0d |D)(ret))|;. }...|
|00001f50| 2f 2a 20 54 68 65 20 72 | 65 61 73 6f 6e 20 77 65 |/* The r|eason we|
|00001f60| 20 68 61 76 65 20 74 68 | 65 73 65 20 73 65 70 65 | have th|ese sepe|
|00001f70| 72 61 74 65 64 20 6c 69 | 6b 65 20 74 68 69 73 20 |rated li|ke this |
|00001f80| 69 6e 73 74 65 61 64 20 | 6f 66 20 75 73 69 6e 67 |instead |of using|
|00001f90| 0d 20 2a 20 61 20 73 74 | 72 75 63 74 75 72 65 20 |. * a st|ructure |
|00001fa0| 6c 69 6b 65 20 74 68 65 | 20 6f 72 69 67 69 6e 61 |like the| origina|
|00001fb0| 6c 20 57 69 6c 68 69 74 | 65 20 63 6f 64 65 20 64 |l Wilhit|e code d|
|00001fc0| 69 64 2c 20 69 73 20 62 | 65 63 61 75 73 65 20 74 |id, is b|ecause t|
|00001fd0| 68 69 73 0d 20 2a 20 73 | 74 75 66 66 20 67 65 6e |his. * s|tuff gen|
|00001fe0| 65 72 61 6c 6c 79 20 70 | 72 6f 64 75 63 65 73 20 |erally p|roduces |
|00001ff0| 73 69 67 6e 69 66 69 63 | 61 6e 74 6c 79 20 66 61 |signific|antly fa|
|00002000| 73 74 65 72 20 63 6f 64 | 65 20 77 68 65 6e 20 63 |ster cod|e when c|
|00002010| 6f 6d 70 69 6c 65 64 2e | 2e 2e 0d 20 2a 20 54 68 |ompiled.|... * Th|
|00002020| 69 73 20 63 6f 64 65 20 | 69 73 20 66 75 6c 6c 20 |is code |is full |
|00002030| 6f 66 20 73 69 6d 69 6c | 61 72 20 73 70 65 65 64 |of simil|ar speed|
|00002040| 75 70 73 2e 2e 2e 20 20 | 28 46 6f 72 20 61 20 67 |ups... |(For a g|
|00002050| 6f 6f 64 20 62 6f 6f 6b | 20 6f 6e 20 77 72 69 74 |ood book| on writ|
|00002060| 69 6e 67 0d 20 2a 20 43 | 20 66 6f 72 20 73 70 65 |ing. * C| for spe|
|00002070| 65 64 20 6f 72 20 66 6f | 72 20 73 70 61 63 65 20 |ed or fo|r space |
|00002080| 6f 70 74 6f 6d 69 73 61 | 74 69 6f 6e 2c 20 73 65 |optomisa|tion, se|
|00002090| 65 20 45 66 66 69 63 69 | 65 6e 74 20 43 20 62 79 |e Effici|ent C by|
|000020a0| 20 54 6f 6d 20 50 6c 75 | 6d 2c 0d 20 2a 20 70 75 | Tom Plu|m,. * pu|
|000020b0| 62 6c 69 73 68 65 64 20 | 62 79 20 50 6c 75 6d 2d |blished |by Plum-|
|000020c0| 48 61 6c 6c 20 41 73 73 | 6f 63 69 61 74 65 73 2e |Hall Ass|ociates.|
|000020d0| 2e 2e 29 0d 20 2a 2f 0d | 0d 2f 2a 0d 49 20 72 65 |..). */.|./*.I re|
|000020e0| 6d 6f 76 65 64 20 74 68 | 65 20 4c 4f 43 41 4c 20 |moved th|e LOCAL |
|000020f0| 69 64 65 6e 74 69 66 69 | 65 72 73 20 69 6e 20 74 |identifi|ers in t|
|00002100| 68 65 20 61 72 72 61 79 | 73 20 62 65 6c 6f 77 20 |he array|s below |
|00002110| 61 6e 64 20 72 65 70 6c | 61 63 65 64 20 74 68 65 |and repl|aced the|
|00002120| 6d 0d 77 69 74 68 20 27 | 65 78 74 65 72 6e 27 73 |m.with '|extern's|
|00002130| 20 73 6f 20 61 73 20 74 | 6f 20 64 65 63 6c 61 72 | so as t|o declar|
|00002140| 65 20 28 61 6e 64 20 72 | 65 2d 75 73 65 29 20 74 |e (and r|e-use) t|
|00002150| 68 65 20 73 70 61 63 65 | 20 65 6c 73 65 77 68 65 |he space| elsewhe|
|00002160| 72 65 2e 0d 54 68 65 20 | 61 72 72 61 79 73 20 61 |re..The |arrays a|
|00002170| 72 65 20 61 63 74 75 61 | 6c 6c 79 20 64 65 63 6c |re actua|lly decl|
|00002180| 61 72 65 64 20 69 6e 20 | 74 68 65 20 61 73 73 65 |ared in |the asse|
|00002190| 6d 62 6c 65 72 20 73 6f | 75 72 63 65 2e 0d 20 20 |mbler so|urce.. |
|000021a0| 20 20 20 20 20 20 20 20 | 20 20 20 20 20 20 20 20 | | |
|000021b0| 20 20 20 20 20 20 20 20 | 20 20 20 20 20 20 20 20 | | |
|000021c0| 20 20 20 20 20 20 20 20 | 20 20 20 20 20 20 20 20 | | |
|000021d0| 20 20 42 65 72 74 20 54 | 79 6c 65 72 0d 2a 2f 0d | Bert T|yler.*/.|
|000021e0| 0d 4c 4f 43 41 4c 20 55 | 54 49 4e 59 20 2a 64 73 |.LOCAL U|TINY *ds|
|000021f0| 74 61 63 6b 3b 20 20 20 | 20 20 20 2f 2a 20 53 74 |tack; | /* St|
|00002200| 61 63 6b 20 66 6f 72 20 | 73 74 6f 72 69 6e 67 20 |ack for |storing |
|00002210| 70 69 78 65 6c 73 20 2a | 2f 0d 4c 4f 43 41 4c 20 |pixels *|/.LOCAL |
|00002220| 55 54 49 4e 59 20 2a 73 | 75 66 66 69 78 3b 20 20 |UTINY *s|uffix; |
|00002230| 20 20 20 20 2f 2a 20 53 | 75 66 66 69 78 20 74 61 | /* S|uffix ta|
|00002240| 62 6c 65 20 2a 2f 0d 4c | 4f 43 41 4c 20 55 57 4f |ble */.L|OCAL UWO|
|00002250| 52 44 20 2a 70 72 65 66 | 69 78 3b 20 20 20 20 20 |RD *pref|ix; |
|00002260| 20 2f 2a 20 50 72 65 66 | 69 78 20 6c 69 6e 6b 65 | /* Pref|ix linke|
|00002270| 64 20 6c 69 73 74 20 2a | 2f 0d 65 78 74 65 72 6e |d list *|/.extern|
|00002280| 20 55 54 49 4e 59 20 2a | 64 65 63 6f 64 65 72 6c | UTINY *|decoderl|
|00002290| 69 6e 65 3b 20 20 20 20 | 20 20 20 20 20 20 20 20 |ine; | |
|000022a0| 20 20 2f 2a 20 64 65 63 | 6f 64 65 64 20 6c 69 6e | /* dec|oded lin|
|000022b0| 65 20 67 6f 65 73 20 68 | 65 72 65 20 2a 2f 0d 0d |e goes h|ere */..|
|000022c0| 2f 2a 20 57 4f 52 44 20 | 64 65 63 6f 64 65 72 28 |/* WORD |decoder(|
|000022d0| 6c 69 6e 65 77 69 64 74 | 68 29 0d 20 2a 20 20 20 |linewidt|h). * |
|000022e0| 20 57 4f 52 44 20 6c 69 | 6e 65 77 69 64 74 68 3b | WORD li|newidth;|
|000022f0| 20 20 20 20 20 20 20 20 | 20 20 20 20 20 20 20 2a | | *|
|00002300| 20 50 69 78 65 6c 73 20 | 70 65 72 20 6c 69 6e 65 | Pixels |per line|
|00002310| 20 6f 66 20 69 6d 61 67 | 65 20 2a 0d 20 2a 0d 20 | of imag|e *. *. |
|00002320| 2a 20 2d 20 54 68 69 73 | 20 66 75 6e 63 74 69 6f |* - This| functio|
|00002330| 6e 20 64 65 63 6f 64 65 | 73 20 61 6e 20 4c 5a 57 |n decode|s an LZW|
|00002340| 20 69 6d 61 67 65 2c 20 | 61 63 63 6f 72 64 69 6e | image, |accordin|
|00002350| 67 20 74 6f 20 74 68 65 | 20 6d 65 74 68 6f 64 20 |g to the| method |
|00002360| 75 73 65 64 0d 20 2a 20 | 69 6e 20 74 68 65 20 47 |used. * |in the G|
|00002370| 49 46 20 73 70 65 63 2e | 20 20 45 76 65 72 79 20 |IF spec.| Every |
|00002380| 2a 6c 69 6e 65 77 69 64 | 74 68 2a 20 22 63 68 61 |*linewid|th* "cha|
|00002390| 72 61 63 74 65 72 73 22 | 20 28 69 65 2e 20 70 69 |racters"| (ie. pi|
|000023a0| 78 65 6c 73 29 20 64 65 | 63 6f 64 65 64 0d 20 2a |xels) de|coded. *|
|000023b0| 20 77 69 6c 6c 20 67 65 | 6e 65 72 61 74 65 20 61 | will ge|nerate a|
|000023c0| 20 63 61 6c 6c 20 74 6f | 20 6f 75 74 5f 6c 69 6e | call to| out_lin|
|000023d0| 65 28 29 2c 20 77 68 69 | 63 68 20 69 73 20 61 20 |e(), whi|ch is a |
|000023e0| 75 73 65 72 20 73 70 65 | 63 69 66 69 63 20 66 75 |user spe|cific fu|
|000023f0| 6e 63 74 69 6f 6e 0d 20 | 2a 20 74 6f 20 64 69 73 |nction. |* to dis|
|00002400| 70 6c 61 79 20 61 20 6c | 69 6e 65 20 6f 66 20 70 |play a l|ine of p|
|00002410| 69 78 65 6c 73 2e 20 20 | 54 68 65 20 66 75 6e 63 |ixels. |The func|
|00002420| 74 69 6f 6e 20 67 65 74 | 73 20 69 74 73 20 63 6f |tion get|s its co|
|00002430| 64 65 73 20 66 72 6f 6d | 0d 20 2a 20 67 65 74 5f |des from|. * get_|
|00002440| 6e 65 78 74 5f 63 6f 64 | 65 28 29 20 77 68 69 63 |next_cod|e() whic|
|00002450| 68 20 69 73 20 72 65 73 | 70 6f 6e 73 69 62 6c 65 |h is res|ponsible|
|00002460| 20 66 6f 72 20 72 65 61 | 64 69 6e 67 20 62 6c 6f | for rea|ding blo|
|00002470| 63 6b 73 20 6f 66 20 64 | 61 74 61 20 61 6e 64 0d |cks of d|ata and.|
|00002480| 20 2a 20 73 65 70 65 72 | 61 74 69 6e 67 20 74 68 | * seper|ating th|
|00002490| 65 6d 20 69 6e 74 6f 20 | 74 68 65 20 70 72 6f 70 |em into |the prop|
|000024a0| 65 72 20 73 69 7a 65 20 | 63 6f 64 65 73 2e 20 20 |er size |codes. |
|000024b0| 46 69 6e 61 6c 6c 79 2c | 20 67 65 74 5f 62 79 74 |Finally,| get_byt|
|000024c0| 65 28 29 20 69 73 0d 20 | 2a 20 74 68 65 20 67 6c |e() is. |* the gl|
|000024d0| 6f 62 61 6c 20 72 6f 75 | 74 69 6e 65 20 74 6f 20 |obal rou|tine to |
|000024e0| 72 65 61 64 20 74 68 65 | 20 6e 65 78 74 20 62 79 |read the| next by|
|000024f0| 74 65 20 66 72 6f 6d 20 | 74 68 65 20 47 49 46 20 |te from |the GIF |
|00002500| 66 69 6c 65 2e 0d 20 2a | 0d 20 2a 20 49 74 20 69 |file.. *|. * It i|
|00002510| 73 20 67 65 6e 65 72 61 | 6c 6c 79 20 61 20 67 6f |s genera|lly a go|
|00002520| 6f 64 20 69 64 65 61 20 | 74 6f 20 68 61 76 65 20 |od idea |to have |
|00002530| 6c 69 6e 65 77 69 64 74 | 68 20 63 6f 72 72 65 73 |linewidt|h corres|
|00002540| 70 6f 6e 64 20 74 6f 20 | 74 68 65 20 61 63 74 75 |pond to |the actu|
|00002550| 61 6c 0d 20 2a 20 77 69 | 64 74 68 20 6f 66 20 61 |al. * wi|dth of a|
|00002560| 20 6c 69 6e 65 20 28 61 | 73 20 73 70 65 63 69 66 | line (a|s specif|
|00002570| 69 65 64 20 69 6e 20 74 | 68 65 20 49 6d 61 67 65 |ied in t|he Image|
|00002580| 20 68 65 61 64 65 72 29 | 20 74 6f 20 6d 61 6b 65 | header)| to make|
|00002590| 20 79 6f 75 72 20 6f 77 | 6e 0d 20 2a 20 63 6f 64 | your ow|n. * cod|
|000025a0| 65 20 61 20 62 69 74 20 | 73 69 6d 70 6c 65 72 2c |e a bit |simpler,|
|000025b0| 20 62 75 74 20 69 74 20 | 69 73 6e 27 74 20 61 62 | but it |isn't ab|
|000025c0| 73 6f 6c 75 74 65 6c 79 | 20 6e 65 63 65 73 73 61 |solutely| necessa|
|000025d0| 72 79 2e 0d 20 2a 0d 20 | 2a 20 52 65 74 75 72 6e |ry.. *. |* Return|
|000025e0| 73 3a 20 30 20 69 66 20 | 73 75 63 63 65 73 73 66 |s: 0 if |successf|
|000025f0| 75 6c 2c 20 65 6c 73 65 | 20 6e 65 67 61 74 69 76 |ul, else| negativ|
|00002600| 65 2e 20 20 28 53 65 65 | 20 45 52 52 53 2e 48 29 |e. (See| ERRS.H)|
|00002610| 0d 20 2a 0d 20 2a 2f 0d | 0d 76 6f 69 64 20 63 6c |. *. */.|.void cl|
|00002620| 65 61 6e 75 70 5f 67 69 | 66 5f 64 65 63 6f 64 65 |eanup_gi|f_decode|
|00002630| 72 28 29 20 0d 20 20 7b | 0d 20 20 66 72 65 65 28 |r() . {|. free(|
|00002640| 64 73 74 61 63 6b 29 3b | 0d 20 20 66 72 65 65 28 |dstack);|. free(|
|00002650| 73 75 66 66 69 78 29 3b | 0d 20 20 66 72 65 65 28 |suffix);|. free(|
|00002660| 70 72 65 66 69 78 29 3b | 0d 20 20 7d 0d 0d 57 4f |prefix);|. }..WO|
|00002670| 52 44 20 64 65 63 6f 64 | 65 72 20 28 69 5f 6c 69 |RD decod|er (i_li|
|00002680| 6e 65 77 69 64 74 68 29 | 0d 69 6e 74 20 69 5f 6c |newidth)|.int i_l|
|00002690| 69 6e 65 77 69 64 74 68 | 3b 0d 20 20 7b 0d 20 20 |inewidth|;. {. |
|000026a0| 57 4f 52 44 20 6c 69 6e | 65 77 69 64 74 68 3b 0d |WORD lin|ewidth;.|
|000026b0| 20 20 46 41 53 54 20 55 | 54 49 4e 59 20 2a 73 70 | FAST U|TINY *sp|
|000026c0| 2c 20 2a 62 75 66 70 74 | 72 3b 0d 20 20 55 54 49 |, *bufpt|r;. UTI|
|000026d0| 4e 59 20 2a 62 75 66 3b | 0d 20 20 46 41 53 54 20 |NY *buf;|. FAST |
|000026e0| 57 4f 52 44 20 63 6f 64 | 65 2c 20 66 63 2c 20 6f |WORD cod|e, fc, o|
|000026f0| 63 2c 20 62 75 66 63 6e | 74 3b 0d 20 20 57 4f 52 |c, bufcn|t;. WOR|
|00002700| 44 20 63 2c 20 73 69 7a | 65 2c 20 72 65 74 3b 0d |D c, siz|e, ret;.|
|00002710| 0d 20 20 6c 69 6e 65 77 | 69 64 74 68 20 3d 20 28 |. linew|idth = (|
|00002720| 57 4f 52 44 29 69 5f 6c | 69 6e 65 77 69 64 74 68 |WORD)i_l|inewidth|
|00002730| 3b 0d 0d 20 20 2f 2a 20 | 49 6e 69 74 69 61 6c 69 |;.. /* |Initiali|
|00002740| 7a 65 20 66 6f 72 20 64 | 65 63 6f 64 69 6e 67 20 |ze for d|ecoding |
|00002750| 61 20 6e 65 77 20 69 6d | 61 67 65 2e 2e 2e 0d 20 |a new im|age.... |
|00002760| 20 20 20 2a 2f 0d 20 20 | 69 66 20 28 28 73 69 7a | */. |if ((siz|
|00002770| 65 20 3d 20 67 65 74 5f | 62 79 74 65 28 29 29 20 |e = get_|byte()) |
|00002780| 3c 20 30 29 0d 20 20 20 | 20 72 65 74 75 72 6e 28 |< 0). | return(|
|00002790| 73 69 7a 65 29 3b 0d 20 | 20 69 66 20 28 73 69 7a |size);. | if (siz|
|000027a0| 65 20 3c 20 32 20 7c 7c | 20 39 20 3c 20 73 69 7a |e < 2 ||| 9 < siz|
|000027b0| 65 29 0d 20 20 20 20 72 | 65 74 75 72 6e 28 42 41 |e). r|eturn(BA|
|000027c0| 44 5f 43 4f 44 45 5f 53 | 49 5a 45 29 3b 0d 20 20 |D_CODE_S|IZE);. |
|000027d0| 69 6e 69 74 5f 65 78 70 | 28 28 69 6e 74 29 73 69 |init_exp|((int)si|
|000027e0| 7a 65 29 3b 20 20 20 20 | 20 20 20 20 2f 2a 20 63 |ze); | /* c|
|000027f0| 68 61 6e 67 65 64 20 70 | 61 72 61 6d 20 74 6f 20 |hanged p|aram to |
|00002800| 69 6e 74 20 2a 2f 0d 0d | 20 20 64 73 74 61 63 6b |int */..| dstack|
|00002810| 20 3d 20 28 55 54 49 4e | 59 20 2a 29 20 6d 61 6c | = (UTIN|Y *) mal|
|00002820| 6c 6f 63 28 28 4d 41 58 | 5f 43 4f 44 45 53 20 2b |loc((MAX|_CODES +|
|00002830| 20 31 29 2a 73 69 7a 65 | 6f 66 28 55 54 49 4e 59 | 1)*size|of(UTINY|
|00002840| 29 29 3b 0d 20 20 73 75 | 66 66 69 78 20 3d 20 28 |));. su|ffix = (|
|00002850| 55 54 49 4e 59 20 2a 29 | 20 6d 61 6c 6c 6f 63 28 |UTINY *)| malloc(|
|00002860| 28 4d 41 58 5f 43 4f 44 | 45 53 20 2b 20 31 29 2a |(MAX_COD|ES + 1)*|
|00002870| 73 69 7a 65 6f 66 28 55 | 54 49 4e 59 29 29 3b 0d |sizeof(U|TINY));.|
|00002880| 20 20 70 72 65 66 69 78 | 20 3d 20 28 55 57 4f 52 | prefix| = (UWOR|
|00002890| 44 20 2a 29 20 6d 61 6c | 6c 6f 63 28 28 4d 41 58 |D *) mal|loc((MAX|
|000028a0| 5f 43 4f 44 45 53 20 2b | 20 31 29 2a 73 69 7a 65 |_CODES +| 1)*size|
|000028b0| 6f 66 28 55 57 4f 52 44 | 29 29 3b 0d 0d 20 20 2f |of(UWORD|));.. /|
|000028c0| 2a 20 49 6e 69 74 69 61 | 6c 69 7a 65 20 69 6e 20 |* Initia|lize in |
|000028d0| 63 61 73 65 20 74 68 65 | 79 20 66 6f 72 67 6f 74 |case the|y forgot|
|000028e0| 20 74 6f 20 70 75 74 20 | 69 6e 20 61 20 63 6c 65 | to put |in a cle|
|000028f0| 61 72 20 63 6f 64 65 2e | 0d 20 20 20 20 2a 20 28 |ar code.|. * (|
|00002900| 54 68 69 73 20 73 68 6f | 75 6c 64 6e 27 74 20 68 |This sho|uldn't h|
|00002910| 61 70 70 65 6e 2c 20 62 | 75 74 20 77 65 27 6c 6c |appen, b|ut we'll|
|00002920| 20 74 72 79 20 61 6e 64 | 20 64 65 63 6f 64 65 20 | try and| decode |
|00002930| 69 74 20 61 6e 79 77 61 | 79 2e 2e 2e 29 0d 20 20 |it anywa|y...). |
|00002940| 20 20 2a 2f 0d 20 20 6f | 63 20 3d 20 66 63 20 3d | */. o|c = fc =|
|00002950| 20 30 3b 0d 0d 20 20 62 | 75 66 20 3d 20 64 65 63 | 0;.. b|uf = dec|
|00002960| 6f 64 65 72 6c 69 6e 65 | 3b 0d 0d 20 20 62 61 64 |oderline|;.. bad|
|00002970| 5f 63 6f 64 65 5f 63 6f | 75 6e 74 20 3d 20 30 3b |_code_co|unt = 0;|
|00002980| 0d 0d 20 20 2f 2a 20 53 | 65 74 20 75 70 20 74 68 |.. /* S|et up th|
|00002990| 65 20 73 74 61 63 6b 20 | 70 6f 69 6e 74 65 72 20 |e stack |pointer |
|000029a0| 61 6e 64 20 64 65 63 6f | 64 65 20 62 75 66 66 65 |and deco|de buffe|
|000029b0| 72 20 70 6f 69 6e 74 65 | 72 0d 20 20 20 20 2a 2f |r pointe|r. */|
|000029c0| 0d 20 20 73 70 20 3d 20 | 64 73 74 61 63 6b 3b 0d |. sp = |dstack;.|
|000029d0| 20 20 62 75 66 70 74 72 | 20 3d 20 62 75 66 3b 0d | bufptr| = buf;.|
|000029e0| 20 20 62 75 66 63 6e 74 | 20 3d 20 6c 69 6e 65 77 | bufcnt| = linew|
|000029f0| 69 64 74 68 3b 0d 0d 20 | 20 2f 2a 20 54 68 69 73 |idth;.. | /* This|
|00002a00| 20 69 73 20 74 68 65 20 | 6d 61 69 6e 20 6c 6f 6f | is the |main loo|
|00002a10| 70 2e 20 20 46 6f 72 20 | 65 61 63 68 20 63 6f 64 |p. For |each cod|
|00002a20| 65 20 77 65 20 67 65 74 | 20 77 65 20 70 61 73 73 |e we get| we pass|
|00002a30| 20 74 68 72 6f 75 67 68 | 20 74 68 65 0d 20 20 20 | through| the. |
|00002a40| 20 2a 20 6c 69 6e 6b 65 | 64 20 6c 69 73 74 20 6f | * linke|d list o|
|00002a50| 66 20 70 72 65 66 69 78 | 20 63 6f 64 65 73 2c 20 |f prefix| codes, |
|00002a60| 70 75 73 68 69 6e 67 20 | 74 68 65 20 63 6f 72 72 |pushing |the corr|
|00002a70| 65 73 70 6f 6e 64 69 6e | 67 20 22 63 68 61 72 61 |espondin|g "chara|
|00002a80| 63 74 65 72 22 20 66 6f | 72 0d 20 20 20 20 2a 20 |cter" fo|r. * |
|00002a90| 65 61 63 68 20 63 6f 64 | 65 20 6f 6e 74 6f 20 74 |each cod|e onto t|
|00002aa0| 68 65 20 73 74 61 63 6b | 2e 20 20 57 68 65 6e 20 |he stack|. When |
|00002ab0| 74 68 65 20 6c 69 73 74 | 20 72 65 61 63 68 65 73 |the list| reaches|
|00002ac0| 20 61 20 73 69 6e 67 6c | 65 20 22 63 68 61 72 61 | a singl|e "chara|
|00002ad0| 63 74 65 72 22 0d 20 20 | 20 20 2a 20 77 65 20 70 |cter". | * we p|
|00002ae0| 75 73 68 20 74 68 61 74 | 20 6f 6e 20 74 68 65 20 |ush that| on the |
|00002af0| 73 74 61 63 6b 20 74 6f | 6f 2c 20 61 6e 64 20 74 |stack to|o, and t|
|00002b00| 68 65 6e 20 73 74 61 72 | 74 20 75 6e 73 74 61 63 |hen star|t unstac|
|00002b10| 6b 69 6e 67 20 65 61 63 | 68 0d 20 20 20 20 2a 20 |king eac|h. * |
|00002b20| 63 68 61 72 61 63 74 65 | 72 20 66 6f 72 20 6f 75 |characte|r for ou|
|00002b30| 74 70 75 74 20 69 6e 20 | 74 68 65 20 63 6f 72 72 |tput in |the corr|
|00002b40| 65 63 74 20 6f 72 64 65 | 72 2e 20 20 53 70 65 63 |ect orde|r. Spec|
|00002b50| 69 61 6c 20 68 61 6e 64 | 6c 69 6e 67 20 69 73 0d |ial hand|ling is.|
|00002b60| 20 20 20 20 2a 20 69 6e | 63 6c 75 64 65 64 20 66 | * in|cluded f|
|00002b70| 6f 72 20 74 68 65 20 63 | 6c 65 61 72 20 63 6f 64 |or the c|lear cod|
|00002b80| 65 2c 20 61 6e 64 20 74 | 68 65 20 77 68 6f 6c 65 |e, and t|he whole|
|00002b90| 20 74 68 69 6e 67 20 65 | 6e 64 73 20 77 68 65 6e | thing e|nds when|
|00002ba0| 20 77 65 20 67 65 74 0d | 20 20 20 20 2a 20 61 6e | we get.| * an|
|00002bb0| 20 65 6e 64 69 6e 67 20 | 63 6f 64 65 2e 0d 20 20 | ending |code.. |
|00002bc0| 20 20 2a 2f 0d 20 20 77 | 68 69 6c 65 20 28 28 63 | */. w|hile ((c|
|00002bd0| 20 3d 20 67 65 74 5f 6e | 65 78 74 5f 63 6f 64 65 | = get_n|ext_code|
|00002be0| 28 29 29 20 21 3d 20 65 | 6e 64 69 6e 67 29 0d 20 |()) != e|nding). |
|00002bf0| 20 20 20 7b 0d 0d 20 20 | 20 20 2f 2a 20 49 66 20 | {.. | /* If |
|00002c00| 77 65 20 68 61 64 20 61 | 20 66 69 6c 65 20 65 72 |we had a| file er|
|00002c10| 72 6f 72 2c 20 72 65 74 | 75 72 6e 20 77 69 74 68 |ror, ret|urn with|
|00002c20| 6f 75 74 20 63 6f 6d 70 | 6c 65 74 69 6e 67 20 74 |out comp|leting t|
|00002c30| 68 65 20 64 65 63 6f 64 | 65 0d 20 20 20 20 20 20 |he decod|e. |
|00002c40| 20 2a 2f 0d 20 20 20 20 | 69 66 20 28 63 20 3c 20 | */. |if (c < |
|00002c50| 30 29 20 0d 20 20 20 20 | 20 20 7b 0d 20 20 20 20 |0) . | {. |
|00002c60| 20 20 63 6c 65 61 6e 75 | 70 5f 67 69 66 5f 64 65 | cleanu|p_gif_de|
|00002c70| 63 6f 64 65 72 28 29 3b | 0d 20 20 20 20 20 20 72 |coder();|. r|
|00002c80| 65 74 75 72 6e 28 30 29 | 3b 0d 20 20 20 20 20 20 |eturn(0)|;. |
|00002c90| 7d 0d 0d 20 20 20 20 2f | 2a 20 49 66 20 74 68 65 |}.. /|* If the|
|00002ca0| 20 63 6f 64 65 20 69 73 | 20 61 20 63 6c 65 61 72 | code is| a clear|
|00002cb0| 20 63 6f 64 65 2c 20 72 | 65 69 6e 69 74 69 61 6c | code, r|einitial|
|00002cc0| 69 7a 65 20 61 6c 6c 20 | 6e 65 63 65 73 73 61 72 |ize all |necessar|
|00002cd0| 79 20 69 74 65 6d 73 2e | 0d 20 20 20 20 20 20 20 |y items.|. |
|00002ce0| 2a 2f 0d 20 20 20 20 69 | 66 20 28 63 20 3d 3d 20 |*/. i|f (c == |
|00002cf0| 63 6c 65 61 72 29 0d 20 | 20 20 20 20 20 7b 0d 20 |clear). | {. |
|00002d00| 20 20 20 20 20 63 75 72 | 72 5f 73 69 7a 65 20 3d | cur|r_size =|
|00002d10| 20 73 69 7a 65 20 2b 20 | 31 3b 0d 20 20 20 20 20 | size + |1;. |
|00002d20| 20 73 6c 6f 74 20 3d 20 | 6e 65 77 63 6f 64 65 73 | slot = |newcodes|
|00002d30| 3b 0d 20 20 20 20 20 20 | 74 6f 70 5f 73 6c 6f 74 |;. |top_slot|
|00002d40| 20 3d 20 31 20 3c 3c 20 | 63 75 72 72 5f 73 69 7a | = 1 << |curr_siz|
|00002d50| 65 3b 0d 0d 20 20 20 20 | 20 20 2f 2a 20 43 6f 6e |e;.. | /* Con|
|00002d60| 74 69 6e 75 65 20 72 65 | 61 64 69 6e 67 20 63 6f |tinue re|ading co|
|00002d70| 64 65 73 20 75 6e 74 69 | 6c 20 77 65 20 67 65 74 |des unti|l we get|
|00002d80| 20 61 20 6e 6f 6e 2d 63 | 6c 65 61 72 20 63 6f 64 | a non-c|lear cod|
|00002d90| 65 0d 20 20 20 20 20 20 | 20 20 20 20 2a 20 28 41 |e. | * (A|
|00002da0| 6e 6f 74 68 65 72 20 75 | 6e 6c 69 6b 65 6c 79 2c |nother u|nlikely,|
|00002db0| 20 62 75 74 20 70 6f 73 | 73 69 62 6c 65 20 63 61 | but pos|sible ca|
|00002dc0| 73 65 2e 2e 2e 29 0d 20 | 20 20 20 20 20 20 20 20 |se...). | |
|00002dd0| 20 2a 2f 0d 20 20 20 20 | 20 20 77 68 69 6c 65 20 | */. | while |
|00002de0| 28 28 63 20 3d 20 67 65 | 74 5f 6e 65 78 74 5f 63 |((c = ge|t_next_c|
|00002df0| 6f 64 65 28 29 29 20 3d | 3d 20 63 6c 65 61 72 29 |ode()) =|= clear)|
|00002e00| 0d 20 20 20 20 20 20 20 | 20 3b 0d 0d 20 20 20 20 |. | ;.. |
|00002e10| 20 20 2f 2a 20 49 66 20 | 77 65 20 67 65 74 20 61 | /* If |we get a|
|00002e20| 6e 20 65 6e 64 69 6e 67 | 20 63 6f 64 65 20 69 6d |n ending| code im|
|00002e30| 6d 65 64 69 61 74 65 6c | 79 20 61 66 74 65 72 20 |mediatel|y after |
|00002e40| 61 20 63 6c 65 61 72 20 | 63 6f 64 65 0d 20 20 20 |a clear |code. |
|00002e50| 20 20 20 20 20 20 20 2a | 20 28 59 65 74 20 61 6e | *| (Yet an|
|00002e60| 6f 74 68 65 72 20 75 6e | 6c 69 6b 65 6c 79 20 63 |other un|likely c|
|00002e70| 61 73 65 29 2c 20 74 68 | 65 6e 20 62 72 65 61 6b |ase), th|en break|
|00002e80| 20 6f 75 74 20 6f 66 20 | 74 68 65 20 6c 6f 6f 70 | out of |the loop|
|00002e90| 2e 0d 20 20 20 20 20 20 | 20 20 20 20 2a 2f 0d 20 |.. | */. |
|00002ea0| 20 20 20 20 20 69 66 20 | 28 63 20 3d 3d 20 65 6e | if |(c == en|
|00002eb0| 64 69 6e 67 29 0d 20 20 | 20 20 20 20 20 20 62 72 |ding). | br|
|00002ec0| 65 61 6b 3b 0d 0d 20 20 | 20 20 20 20 2f 2a 20 46 |eak;.. | /* F|
|00002ed0| 69 6e 61 6c 6c 79 2c 20 | 69 66 20 74 68 65 20 63 |inally, |if the c|
|00002ee0| 6f 64 65 20 69 73 20 62 | 65 79 6f 6e 64 20 74 68 |ode is b|eyond th|
|00002ef0| 65 20 72 61 6e 67 65 20 | 6f 66 20 61 6c 72 65 61 |e range |of alrea|
|00002f00| 64 79 20 73 65 74 20 63 | 6f 64 65 73 2c 0d 20 20 |dy set c|odes,. |
|00002f10| 20 20 20 20 20 20 20 20 | 2a 20 28 54 68 69 73 20 | |* (This |
|00002f20| 6f 6e 65 20 68 61 64 20 | 62 65 74 74 65 72 20 4e |one had |better N|
|00002f30| 4f 54 20 68 61 70 70 65 | 6e 2e 2e 2e 20 20 49 20 |OT happe|n... I |
|00002f40| 68 61 76 65 20 6e 6f 20 | 69 64 65 61 20 77 68 61 |have no |idea wha|
|00002f50| 74 20 77 69 6c 6c 0d 20 | 20 20 20 20 20 20 20 20 |t will. | |
|00002f60| 20 2a 20 72 65 73 75 6c | 74 20 66 72 6f 6d 20 74 | * resul|t from t|
|00002f70| 68 69 73 2c 20 62 75 74 | 20 49 20 64 6f 75 62 74 |his, but| I doubt|
|00002f80| 20 69 74 20 77 69 6c 6c | 20 6c 6f 6f 6b 20 67 6f | it will| look go|
|00002f90| 6f 64 2e 2e 2e 29 20 74 | 68 65 6e 20 73 65 74 20 |od...) t|hen set |
|00002fa0| 69 74 0d 20 20 20 20 20 | 20 20 20 20 20 2a 20 74 |it. | * t|
|00002fb0| 6f 20 63 6f 6c 6f 72 20 | 7a 65 72 6f 2e 0d 20 20 |o color |zero.. |
|00002fc0| 20 20 20 20 20 20 20 20 | 2a 2f 0d 20 20 20 20 20 | |*/. |
|00002fd0| 20 69 66 20 28 63 20 3e | 3d 20 73 6c 6f 74 29 0d | if (c >|= slot).|
|00002fe0| 20 20 20 20 20 20 20 20 | 63 20 3d 20 30 3b 0d 0d | |c = 0;..|
|00002ff0| 20 20 20 20 20 20 6f 63 | 20 3d 20 66 63 20 3d 20 | oc| = fc = |
|00003000| 63 3b 0d 0d 20 20 20 20 | 20 20 2f 2a 20 41 6e 64 |c;.. | /* And|
|00003010| 20 6c 65 74 20 75 73 20 | 6e 6f 74 20 66 6f 72 67 | let us |not forg|
|00003020| 65 74 20 74 6f 20 70 75 | 74 20 74 68 65 20 63 68 |et to pu|t the ch|
|00003030| 61 72 20 69 6e 74 6f 20 | 74 68 65 20 62 75 66 66 |ar into |the buff|
|00003040| 65 72 2e 2e 2e 20 41 6e | 64 0d 20 20 20 20 20 20 |er... An|d. |
|00003050| 20 20 20 20 2a 20 69 66 | 2c 20 6f 6e 20 74 68 65 | * if|, on the|
|00003060| 20 6f 66 66 20 63 68 61 | 6e 63 65 2c 20 77 65 20 | off cha|nce, we |
|00003070| 77 65 72 65 20 65 78 61 | 63 74 6c 79 20 6f 6e 65 |were exa|ctly one|
|00003080| 20 70 69 78 65 6c 20 66 | 72 6f 6d 20 74 68 65 20 | pixel f|rom the |
|00003090| 65 6e 64 0d 20 20 20 20 | 20 20 20 20 20 20 2a 20 |end. | * |
|000030a0| 6f 66 20 74 68 65 20 6c | 69 6e 65 2c 20 77 65 20 |of the l|ine, we |
|000030b0| 68 61 76 65 20 74 6f 20 | 73 65 6e 64 20 74 68 65 |have to |send the|
|000030c0| 20 62 75 66 66 65 72 20 | 74 6f 20 74 68 65 20 6f | buffer |to the o|
|000030d0| 75 74 5f 6c 69 6e 65 28 | 29 0d 20 20 20 20 20 20 |ut_line(|). |
|000030e0| 20 20 20 20 2a 20 72 6f | 75 74 69 6e 65 2e 2e 2e | * ro|utine...|
|000030f0| 0d 20 20 20 20 20 20 20 | 20 20 20 2a 2f 0d 20 20 |. | */. |
|00003100| 20 20 20 20 2a 62 75 66 | 70 74 72 2b 2b 20 3d 20 | *buf|ptr++ = |
|00003110| 28 55 54 49 4e 59 29 20 | 63 3b 0d 20 20 20 20 20 |(UTINY) |c;. |
|00003120| 20 69 66 20 28 2d 2d 62 | 75 66 63 6e 74 20 3d 3d | if (--b|ufcnt ==|
|00003130| 20 30 29 0d 20 20 20 20 | 20 20 20 20 7b 0d 20 20 | 0). | {. |
|00003140| 20 20 20 20 20 20 43 4f | 4f 50 45 52 41 54 45 0d | CO|OPERATE.|
|00003150| 20 20 20 20 20 20 20 20 | 69 66 20 28 28 72 65 74 | |if ((ret|
|00003160| 20 3d 20 6f 75 74 5f 6c | 69 6e 65 28 62 75 66 2c | = out_l|ine(buf,|
|00003170| 20 6c 69 6e 65 77 69 64 | 74 68 29 29 20 3c 20 30 | linewid|th)) < 0|
|00003180| 29 20 0d 20 20 20 20 20 | 20 20 20 20 20 7b 0d 20 |) . | {. |
|00003190| 20 20 20 20 20 20 20 20 | 20 63 6c 65 61 6e 75 70 | | cleanup|
|000031a0| 5f 67 69 66 5f 64 65 63 | 6f 64 65 72 28 29 3b 0d |_gif_dec|oder();.|
|000031b0| 20 20 20 20 20 20 20 20 | 20 20 72 65 74 75 72 6e | | return|
|000031c0| 28 72 65 74 29 3b 0d 20 | 20 20 20 20 20 20 20 20 |(ret);. | |
|000031d0| 20 7d 0d 0d 20 20 20 20 | 20 20 20 20 62 75 66 70 | }.. | bufp|
|000031e0| 74 72 20 3d 20 62 75 66 | 3b 0d 20 20 20 20 20 20 |tr = buf|;. |
|000031f0| 20 20 62 75 66 63 6e 74 | 20 3d 20 6c 69 6e 65 77 | bufcnt| = linew|
|00003200| 69 64 74 68 3b 0d 20 20 | 20 20 20 20 20 20 7d 0d |idth;. | }.|
|00003210| 20 20 20 20 20 20 7d 0d | 20 20 20 20 65 6c 73 65 | }.| else|
|00003220| 0d 20 20 20 20 20 20 7b | 0d 0d 20 20 20 20 20 20 |. {|.. |
|00003230| 2f 2a 20 49 6e 20 74 68 | 69 73 20 63 61 73 65 2c |/* In th|is case,|
|00003240| 20 69 74 27 73 20 6e 6f | 74 20 61 20 63 6c 65 61 | it's no|t a clea|
|00003250| 72 20 63 6f 64 65 20 6f | 72 20 61 6e 20 65 6e 64 |r code o|r an end|
|00003260| 69 6e 67 20 63 6f 64 65 | 2c 20 73 6f 0d 20 20 20 |ing code|, so. |
|00003270| 20 20 20 20 20 20 20 2a | 20 69 74 20 6d 75 73 74 | *| it must|
|00003280| 20 62 65 20 61 20 63 6f | 64 65 20 63 6f 64 65 2e | be a co|de code.|
|00003290| 2e 2e 20 20 53 6f 20 77 | 65 20 63 61 6e 20 6e 6f |.. So w|e can no|
|000032a0| 77 20 64 65 63 6f 64 65 | 20 74 68 65 20 63 6f 64 |w decode| the cod|
|000032b0| 65 20 69 6e 74 6f 0d 20 | 20 20 20 20 20 20 20 20 |e into. | |
|000032c0| 20 2a 20 61 20 73 74 61 | 63 6b 20 6f 66 20 63 68 | * a sta|ck of ch|
|000032d0| 61 72 61 63 74 65 72 20 | 63 6f 64 65 73 2e 20 28 |aracter |codes. (|
|000032e0| 43 6c 65 61 72 20 61 73 | 20 6d 75 64 2c 20 72 69 |Clear as| mud, ri|
|000032f0| 67 68 74 3f 29 0d 20 20 | 20 20 20 20 20 20 20 20 |ght?). | |
|00003300| 2a 2f 0d 20 20 20 20 20 | 20 63 6f 64 65 20 3d 20 |*/. | code = |
|00003310| 63 3b 0d 0d 20 20 20 20 | 20 20 2f 2a 20 48 65 72 |c;.. | /* Her|
|00003320| 65 20 77 65 20 67 6f 20 | 61 67 61 69 6e 20 77 69 |e we go |again wi|
|00003330| 74 68 20 6f 6e 65 20 6f | 66 20 74 68 6f 73 65 20 |th one o|f those |
|00003340| 6f 66 66 20 63 68 61 6e | 63 65 73 2e 2e 2e 20 20 |off chan|ces... |
|00003350| 49 66 2c 20 6f 6e 20 74 | 68 65 0d 20 20 20 20 20 |If, on t|he. |
|00003360| 20 20 20 20 20 2a 20 6f | 66 66 20 63 68 61 6e 63 | * o|ff chanc|
|00003370| 65 2c 20 74 68 65 20 63 | 6f 64 65 20 77 65 20 67 |e, the c|ode we g|
|00003380| 6f 74 20 69 73 20 62 65 | 79 6f 6e 64 20 74 68 65 |ot is be|yond the|
|00003390| 20 72 61 6e 67 65 20 6f | 66 20 74 68 6f 73 65 20 | range o|f those |
|000033a0| 61 6c 72 65 61 64 79 0d | 20 20 20 20 20 20 20 20 |already.| |
|000033b0| 20 20 2a 20 73 65 74 20 | 75 70 20 28 41 6e 6f 74 | * set |up (Anot|
|000033c0| 68 65 72 20 74 68 69 6e | 67 20 77 68 69 63 68 20 |her thin|g which |
|000033d0| 68 61 64 20 62 65 74 74 | 65 72 20 4e 4f 54 20 68 |had bett|er NOT h|
|000033e0| 61 70 70 65 6e 2e 2e 2e | 29 20 77 65 20 74 72 69 |appen...|) we tri|
|000033f0| 63 6b 0d 20 20 20 20 20 | 20 20 20 20 20 2a 20 74 |ck. | * t|
|00003400| 68 65 20 64 65 63 6f 64 | 65 72 20 69 6e 74 6f 20 |he decod|er into |
|00003410| 74 68 69 6e 6b 69 6e 67 | 20 69 74 20 61 63 74 75 |thinking| it actu|
|00003420| 61 6c 6c 79 20 67 6f 74 | 20 74 68 65 20 6c 61 73 |ally got| the las|
|00003430| 74 20 63 6f 64 65 20 72 | 65 61 64 2e 0d 20 20 20 |t code r|ead.. |
|00003440| 20 20 20 20 20 20 20 2a | 20 28 48 6d 6d 6e 2e 2e | *| (Hmmn..|
|00003450| 2e 20 49 27 6d 20 6e 6f | 74 20 73 75 72 65 20 77 |. I'm no|t sure w|
|00003460| 68 79 20 74 68 69 73 20 | 77 6f 72 6b 73 2e 2e 2e |hy this |works...|
|00003470| 20 20 42 75 74 20 69 74 | 20 64 6f 65 73 2e 2e 2e | But it| does...|
|00003480| 29 0d 20 20 20 20 20 20 | 20 20 20 20 2a 2f 0d 20 |). | */. |
|00003490| 20 20 20 20 20 69 66 20 | 28 63 6f 64 65 20 3e 3d | if |(code >=|
|000034a0| 20 73 6c 6f 74 29 0d 20 | 20 20 20 20 20 20 20 7b | slot). | {|
|000034b0| 0d 20 20 20 20 20 20 20 | 20 69 66 20 28 63 6f 64 |. | if (cod|
|000034c0| 65 20 3e 20 73 6c 6f 74 | 29 0d 20 20 20 20 20 20 |e > slot|). |
|000034d0| 20 20 20 20 2b 2b 62 61 | 64 5f 63 6f 64 65 5f 63 | ++ba|d_code_c|
|000034e0| 6f 75 6e 74 3b 0d 20 20 | 20 20 20 20 20 20 63 6f |ount;. | co|
|000034f0| 64 65 20 3d 20 6f 63 3b | 0d 20 20 20 20 20 20 20 |de = oc;|. |
|00003500| 20 2a 73 70 2b 2b 20 3d | 20 28 55 54 49 4e 59 29 | *sp++ =| (UTINY)|
|00003510| 20 66 63 3b 0d 20 20 20 | 20 20 20 20 20 7d 0d 0d | fc;. | }..|
|00003520| 20 20 20 20 20 20 2f 2a | 20 48 65 72 65 20 77 65 | /*| Here we|
|00003530| 20 73 63 61 6e 20 62 61 | 63 6b 20 61 6c 6f 6e 67 | scan ba|ck along|
|00003540| 20 74 68 65 20 6c 69 6e | 6b 65 64 20 6c 69 73 74 | the lin|ked list|
|00003550| 20 6f 66 20 70 72 65 66 | 69 78 65 73 2c 20 70 75 | of pref|ixes, pu|
|00003560| 73 68 69 6e 67 0d 20 20 | 20 20 20 20 20 20 20 20 |shing. | |
|00003570| 2a 20 68 65 6c 70 6c 65 | 73 73 20 63 68 61 72 61 |* helple|ss chara|
|00003580| 63 74 65 72 73 20 28 69 | 65 2e 20 73 75 66 66 69 |cters (i|e. suffi|
|00003590| 78 65 73 29 20 6f 6e 74 | 6f 20 74 68 65 20 73 74 |xes) ont|o the st|
|000035a0| 61 63 6b 20 61 73 20 77 | 65 20 64 6f 20 73 6f 2e |ack as w|e do so.|
|000035b0| 0d 20 20 20 20 20 20 20 | 20 20 20 2a 2f 0d 20 20 |. | */. |
|000035c0| 20 20 20 20 77 68 69 6c | 65 20 28 63 6f 64 65 20 | whil|e (code |
|000035d0| 3e 3d 20 6e 65 77 63 6f | 64 65 73 29 0d 20 20 20 |>= newco|des). |
|000035e0| 20 20 20 20 20 7b 0d 20 | 20 20 20 20 20 20 20 2a | {. | *|
|000035f0| 73 70 2b 2b 20 3d 20 73 | 75 66 66 69 78 5b 63 6f |sp++ = s|uffix[co|
|00003600| 64 65 5d 3b 0d 20 20 20 | 20 20 20 20 20 63 6f 64 |de];. | cod|
|00003610| 65 20 3d 20 70 72 65 66 | 69 78 5b 63 6f 64 65 5d |e = pref|ix[code]|
|00003620| 3b 0d 20 20 20 20 20 20 | 20 20 7d 0d 0d 20 20 20 |;. | }.. |
|00003630| 20 20 20 2f 2a 20 50 75 | 73 68 20 74 68 65 20 6c | /* Pu|sh the l|
|00003640| 61 73 74 20 63 68 61 72 | 61 63 74 65 72 20 6f 6e |ast char|acter on|
|00003650| 20 74 68 65 20 73 74 61 | 63 6b 2c 20 61 6e 64 20 | the sta|ck, and |
|00003660| 73 65 74 20 75 70 20 74 | 68 65 20 6e 65 77 0d 20 |set up t|he new. |
|00003670| 20 20 20 20 20 20 20 20 | 20 2a 20 70 72 65 66 69 | | * prefi|
|00003680| 78 20 61 6e 64 20 73 75 | 66 66 69 78 2c 20 61 6e |x and su|ffix, an|
|00003690| 64 20 69 66 20 74 68 65 | 20 72 65 71 75 69 72 65 |d if the| require|
|000036a0| 64 20 73 6c 6f 74 20 6e | 75 6d 62 65 72 20 69 73 |d slot n|umber is|
|000036b0| 20 67 72 65 61 74 65 72 | 0d 20 20 20 20 20 20 20 | greater|. |
|000036c0| 20 20 20 2a 20 74 68 61 | 6e 20 74 68 61 74 20 61 | * tha|n that a|
|000036d0| 6c 6c 6f 77 65 64 20 62 | 79 20 74 68 65 20 63 75 |llowed b|y the cu|
|000036e0| 72 72 65 6e 74 20 62 69 | 74 20 73 69 7a 65 2c 20 |rrent bi|t size, |
|000036f0| 69 6e 63 72 65 61 73 65 | 20 74 68 65 20 62 69 74 |increase| the bit|
|00003700| 0d 20 20 20 20 20 20 20 | 20 20 20 2a 20 73 69 7a |. | * siz|
|00003710| 65 2e 20 20 28 4e 4f 54 | 45 20 2d 20 49 66 20 77 |e. (NOT|E - If w|
|00003720| 65 20 61 72 65 20 61 6c | 6c 20 66 75 6c 6c 2c 20 |e are al|l full, |
|00003730| 77 65 20 2a 64 6f 6e 27 | 74 2a 20 73 61 76 65 20 |we *don'|t* save |
|00003740| 74 68 65 20 6e 65 77 0d | 20 20 20 20 20 20 20 20 |the new.| |
|00003750| 20 20 2a 20 73 75 66 66 | 69 78 20 61 6e 64 20 70 | * suff|ix and p|
|00003760| 72 65 66 69 78 2e 2e 2e | 20 20 49 27 6d 20 6e 6f |refix...| I'm no|
|00003770| 74 20 63 65 72 74 61 69 | 6e 20 69 66 20 74 68 69 |t certai|n if thi|
|00003780| 73 20 69 73 20 63 6f 72 | 72 65 63 74 2e 2e 2e 0d |s is cor|rect....|
|00003790| 20 20 20 20 20 20 20 20 | 20 20 2a 20 69 74 20 6d | | * it m|
|000037a0| 69 67 68 74 20 62 65 20 | 6d 6f 72 65 20 70 72 6f |ight be |more pro|
|000037b0| 70 65 72 20 74 6f 20 6f | 76 65 72 77 72 69 74 65 |per to o|verwrite|
|000037c0| 20 74 68 65 20 6c 61 73 | 74 20 63 6f 64 65 2e 2e | the las|t code..|
|000037d0| 2e 0d 20 20 20 20 20 20 | 20 20 20 20 2a 2f 0d 20 |.. | */. |
|000037e0| 20 20 20 20 20 2a 73 70 | 2b 2b 20 3d 20 28 55 54 | *sp|++ = (UT|
|000037f0| 49 4e 59 29 20 63 6f 64 | 65 3b 0d 20 20 20 20 20 |INY) cod|e;. |
|00003800| 20 69 66 20 28 73 6c 6f | 74 20 3c 20 74 6f 70 5f | if (slo|t < top_|
|00003810| 73 6c 6f 74 29 0d 20 20 | 20 20 20 20 20 20 7b 0d |slot). | {.|
|00003820| 20 20 20 20 20 20 20 20 | 66 63 20 3d 20 63 6f 64 | |fc = cod|
|00003830| 65 3b 0d 20 20 20 20 20 | 20 20 20 73 75 66 66 69 |e;. | suffi|
|00003840| 78 5b 73 6c 6f 74 5d 20 | 3d 20 28 55 54 49 4e 59 |x[slot] |= (UTINY|
|00003850| 29 20 66 63 3b 0d 20 20 | 20 20 20 20 20 20 70 72 |) fc;. | pr|
|00003860| 65 66 69 78 5b 73 6c 6f | 74 2b 2b 5d 20 3d 20 6f |efix[slo|t++] = o|
|00003870| 63 3b 0d 20 20 20 20 20 | 20 20 20 6f 63 20 3d 20 |c;. | oc = |
|00003880| 63 3b 0d 20 20 20 20 20 | 20 20 20 7d 0d 20 20 20 |c;. | }. |
|00003890| 20 20 20 69 66 20 28 73 | 6c 6f 74 20 3e 3d 20 74 | if (s|lot >= t|
|000038a0| 6f 70 5f 73 6c 6f 74 29 | 0d 20 20 20 20 20 20 20 |op_slot)|. |
|000038b0| 20 69 66 20 28 63 75 72 | 72 5f 73 69 7a 65 20 3c | if (cur|r_size <|
|000038c0| 20 31 32 29 0d 20 20 20 | 20 20 20 20 20 20 20 7b | 12). | {|
|000038d0| 0d 20 20 20 20 20 20 20 | 20 20 20 74 6f 70 5f 73 |. | top_s|
|000038e0| 6c 6f 74 20 3c 3c 3d 20 | 31 3b 0d 20 20 20 20 20 |lot <<= |1;. |
|000038f0| 20 20 20 20 20 2b 2b 63 | 75 72 72 5f 73 69 7a 65 | ++c|urr_size|
|00003900| 3b 0d 20 20 20 20 20 20 | 20 20 20 20 7d 0d 0d 20 |;. | }.. |
|00003910| 20 20 20 20 20 2f 2a 20 | 4e 6f 77 20 74 68 61 74 | /* |Now that|
|00003920| 20 77 65 27 76 65 20 70 | 75 73 68 65 64 20 74 68 | we've p|ushed th|
|00003930| 65 20 64 65 63 6f 64 65 | 64 20 73 74 72 69 6e 67 |e decode|d string|
|00003940| 20 28 69 6e 20 72 65 76 | 65 72 73 65 20 6f 72 64 | (in rev|erse ord|
|00003950| 65 72 29 0d 20 20 20 20 | 20 20 20 20 20 20 2a 20 |er). | * |
|00003960| 6f 6e 74 6f 20 74 68 65 | 20 73 74 61 63 6b 2c 20 |onto the| stack, |
|00003970| 6c 65 74 73 20 70 6f 70 | 20 69 74 20 6f 66 66 20 |lets pop| it off |
|00003980| 61 6e 64 20 70 75 74 20 | 69 74 20 69 6e 74 6f 20 |and put |it into |
|00003990| 6f 75 72 20 64 65 63 6f | 64 65 0d 20 20 20 20 20 |our deco|de. |
|000039a0| 20 20 20 20 20 2a 20 62 | 75 66 66 65 72 2e 2e 2e | * b|uffer...|
|000039b0| 20 20 41 6e 64 20 77 68 | 65 6e 20 74 68 65 20 64 | And wh|en the d|
|000039c0| 65 63 6f 64 65 20 62 75 | 66 66 65 72 20 69 73 20 |ecode bu|ffer is |
|000039d0| 66 75 6c 6c 2c 20 77 72 | 69 74 65 20 61 6e 6f 74 |full, wr|ite anot|
|000039e0| 68 65 72 0d 20 20 20 20 | 20 20 20 20 20 20 2a 20 |her. | * |
|000039f0| 6c 69 6e 65 2e 2e 2e 0d | 20 20 20 20 20 20 20 20 |line....| |
|00003a00| 20 20 2a 2f 0d 20 20 20 | 20 20 20 77 68 69 6c 65 | */. | while|
|00003a10| 20 28 73 70 20 3e 20 64 | 73 74 61 63 6b 29 0d 20 | (sp > d|stack). |
|00003a20| 20 20 20 20 20 20 20 7b | 0d 20 20 20 20 20 20 20 | {|. |
|00003a30| 20 2a 62 75 66 70 74 72 | 2b 2b 20 3d 20 2a 28 2d | *bufptr|++ = *(-|
|00003a40| 2d 73 70 29 3b 0d 20 20 | 20 20 20 20 20 20 69 66 |-sp);. | if|
|00003a50| 20 28 2d 2d 62 75 66 63 | 6e 74 20 3d 3d 20 30 29 | (--bufc|nt == 0)|
|00003a60| 0d 20 20 20 20 20 20 20 | 20 20 20 7b 0d 20 20 20 |. | {. |
|00003a70| 20 20 20 20 20 20 20 43 | 4f 4f 50 45 52 41 54 45 | C|OOPERATE|
|00003a80| 0d 20 20 20 20 20 20 20 | 20 20 20 69 66 20 28 28 |. | if ((|
|00003a90| 72 65 74 20 3d 20 6f 75 | 74 5f 6c 69 6e 65 28 62 |ret = ou|t_line(b|
|00003aa0| 75 66 2c 20 6c 69 6e 65 | 77 69 64 74 68 29 29 20 |uf, line|width)) |
|00003ab0| 3c 20 30 29 20 0d 20 20 | 20 20 20 20 20 20 20 20 |< 0) . | |
|00003ac0| 20 20 7b 0d 20 20 20 20 | 20 20 20 20 20 20 20 20 | {. | |
|00003ad0| 63 6c 65 61 6e 75 70 5f | 67 69 66 5f 64 65 63 6f |cleanup_|gif_deco|
|00003ae0| 64 65 72 28 29 3b 0d 20 | 20 20 20 20 20 20 20 20 |der();. | |
|00003af0| 20 20 20 72 65 74 75 72 | 6e 28 72 65 74 29 3b 0d | retur|n(ret);.|
|00003b00| 20 20 20 20 20 20 20 20 | 20 20 20 20 7d 0d 20 20 | | }. |
|00003b10| 20 20 20 20 20 20 20 20 | 62 75 66 70 74 72 20 3d | |bufptr =|
|00003b20| 20 62 75 66 3b 0d 20 20 | 20 20 20 20 20 20 20 20 | buf;. | |
|00003b30| 62 75 66 63 6e 74 20 3d | 20 6c 69 6e 65 77 69 64 |bufcnt =| linewid|
|00003b40| 74 68 3b 0d 20 20 20 20 | 20 20 20 20 20 20 7d 0d |th;. | }.|
|00003b50| 20 20 20 20 20 20 20 20 | 7d 0d 20 20 20 20 20 20 | |}. |
|00003b60| 7d 0d 20 20 20 20 7d 0d | 20 20 72 65 74 20 3d 20 |}. }.| ret = |
|00003b70| 30 3b 0d 20 20 69 66 20 | 28 62 75 66 63 6e 74 20 |0;. if |(bufcnt |
|00003b80| 21 3d 20 6c 69 6e 65 77 | 69 64 74 68 29 0d 20 20 |!= linew|idth). |
|00003b90| 20 20 72 65 74 20 3d 20 | 6f 75 74 5f 6c 69 6e 65 | ret = |out_line|
|00003ba0| 28 62 75 66 2c 20 28 6c | 69 6e 65 77 69 64 74 68 |(buf, (l|inewidth|
|00003bb0| 20 2d 20 62 75 66 63 6e | 74 29 29 3b 0d 0d 20 20 | - bufcn|t));.. |
|00003bc0| 63 6c 65 61 6e 75 70 5f | 67 69 66 5f 64 65 63 6f |cleanup_|gif_deco|
|00003bd0| 64 65 72 28 29 3b 0d 20 | 20 72 65 74 75 72 6e 28 |der();. | return(|
|00003be0| 72 65 74 29 3b 0d 20 20 | 7d 0d 00 00 00 00 00 00 |ret);. |}.......|
|00003bf0| 00 00 00 00 00 00 00 00 | 00 00 00 00 00 00 00 00 |........|........|
|00003c00| 00 00 01 00 00 00 01 6e | 00 00 00 6e 00 00 00 3e |.......n|...n...>|
|00003c10| 00 00 01 5d 0d 20 2e 6f | 20 43 6f 6e 76 65 72 74 |...]. .o| Convert|
|00003c20| 65 72 02 00 00 00 54 52 | 41 4e 6f 43 6e 76 21 00 |er....TR|ANoCnv!.|
|00003c30| 0a 47 49 46 44 45 43 4f | 44 2e 43 00 02 00 00 00 |.GIFDECO|D.C.....|
|00003c40| 54 45 58 54 4d 50 53 20 | 01 08 ff ff ff ff 00 00 |TEXTMPS |........|
|00003c50| 00 00 54 45 58 54 4d 50 | 53 20 01 08 ff ff ff ff |..TEXTMP|S ......|
|00003c60| 00 00 00 00 00 00 00 00 | 00 00 00 00 00 00 00 00 |........|........|
|00003c70| 00 00 a8 88 13 ec 00 00 | 3b 6a 00 00 01 ac 00 00 |........|;j......|
|00003c80| 00 00 00 00 00 00 00 00 | 15 00 00 00 01 5d 0f 52 |........|.....].R|
|00003c90| 65 73 6f 75 72 63 65 20 | 43 6f 70 69 65 72 02 00 |esource |Copier..|
|00003ca0| 00 00 54 52 41 4e 52 53 | 43 d7 21 00 00 34 00 80 |..TRANRS|C.!..4..|
|00003cb0| 00 00 00 00 01 60 00 00 | 00 00 00 00 00 00 00 00 |.....`..|........|
|00003cc0| 00 00 00 00 1b 64 00 00 | 1c 00 a8 08 1a bf a8 08 |.....d..|........|
|00003cd0| 1a c1 a9 47 50 07 00 00 | 00 00 00 00 00 00 00 00 |...GP...|........|
|00003ce0| 00 00 00 00 00 00 00 00 | 00 00 00 00 00 00 00 00 |........|........|
|00003cf0| 00 00 00 00 13 51 00 07 | 00 00 00 00 00 00 00 00 |.....Q..|........|
|00003d00| 00 00 00 48 00 09 4d 6f | 6e 61 63 6f 00 00 00 00 |...H..Mo|naco....|
|00003d10| 00 00 00 00 00 00 00 00 | 00 00 00 00 00 00 01 0c |........|........|
|00003d20| 00 00 00 00 00 00 00 06 | 00 04 01 54 00 00 01 dd |........|...T....|
|00003d30| 02 3d 01 54 00 00 01 dd | 02 3d a8 88 13 ec 00 00 |.=.T....|.=......|
|00003d40| 00 00 00 00 00 00 00 00 | 00 00 01 00 00 00 00 1e |........|........|
|00003d50| 01 54 00 00 01 dd 02 3d | 01 54 00 00 01 dd 02 3d |.T.....=|.T.....=|
|00003d60| 00 00 00 00 00 00 00 00 | 00 00 00 00 00 00 00 00 |........|........|
|00003d70| 01 00 00 00 01 6e 00 00 | 00 6e 00 00 00 3e 00 8d |.....n..|.n...>..|
|00003d80| 3b f8 18 3e 00 00 00 1c | 00 3e 00 00 4d 50 53 52 |;..>....|.>..MPSR|
|00003d90| 00 01 00 0a 03 ed ff ff | 00 00 00 00 00 00 00 00 |........|........|
|00003da0| 03 f0 ff ff 00 00 00 4c | 00 8f 92 b0 00 00 00 00 |.......L|........|
|00003db0| 00 00 00 00 00 00 00 00 | 00 00 00 00 00 00 00 00 |........|........|
|00003dc0| 00 00 00 00 00 00 00 00 | 00 00 00 00 00 00 00 00 |........|........|
|00003dd0| 00 00 00 00 00 00 00 00 | 00 00 00 00 00 00 00 00 |........|........|
|00003de0| 00 00 00 00 00 00 00 00 | 00 00 00 00 00 00 00 00 |........|........|
|00003df0| 00 00 00 00 00 00 00 00 | 00 00 00 00 00 00 00 00 |........|........|
+--------+-------------------------+-------------------------+--------+--------+